diff --git a/libs/ZeroMQ.dll b/libs/ZeroMQ.dll index 52f94cbebf..90282be6d1 100644 Binary files a/libs/ZeroMQ.dll and b/libs/ZeroMQ.dll differ diff --git a/libs/runtimes/win-x64/libcryptonight.dll b/libs/runtimes/win-x64/libcryptonight.dll deleted file mode 100644 index deb59a01fb..0000000000 Binary files a/libs/runtimes/win-x64/libcryptonight.dll and /dev/null differ diff --git a/libs/runtimes/win-x64/libmultihash.dll b/libs/runtimes/win-x64/libmultihash.dll index f141fc95e1..7344acb077 100644 Binary files a/libs/runtimes/win-x64/libmultihash.dll and b/libs/runtimes/win-x64/libmultihash.dll differ diff --git a/libs/runtimes/win-x64/librandomx.dll b/libs/runtimes/win-x64/librandomx.dll new file mode 100644 index 0000000000..4fe4436a70 Binary files /dev/null and b/libs/runtimes/win-x64/librandomx.dll differ diff --git a/src/Miningcore.Tests/Blockchain/Bitcoin/BitcoinJobTests.cs b/src/Miningcore.Tests/Blockchain/Bitcoin/BitcoinJobTests.cs deleted file mode 100644 index bcdd1f21ba..0000000000 --- a/src/Miningcore.Tests/Blockchain/Bitcoin/BitcoinJobTests.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using Miningcore.Blockchain.Bitcoin; -using Miningcore.Configuration; -using Miningcore.Crypto; -using Miningcore.Crypto.Hashing.Algorithms; -using Miningcore.Extensions; -using Miningcore.Stratum; -using Miningcore.Tests.Util; -using NBitcoin; -using Newtonsoft.Json; -using Xunit; - -namespace Miningcore.Tests.Blockchain.Bitcoin -{ - public class BitcoinJobTests : TestBase - { - public BitcoinJobTests() - { - poolConfig = new PoolConfig - { - Coin = "bitcoin", - Template = ModuleInitializer.CoinTemplates["bitcoin"] - }; - } - - readonly PoolConfig poolConfig; - - readonly ClusterConfig clusterConfig = new ClusterConfig(); - private readonly IDestination poolAddressDestination = BitcoinUtils.AddressToDestination("mjn3q42yxr9yLA3gyseHCZCHEptZC31PEh", Network.RegTest); - - protected readonly IHashAlgorithm sha256d = new Sha256D(); - protected readonly IHashAlgorithm sha256dReverse = new DigestReverser(new Sha256D()); - - [Fact] - public void BitcoinJob_Should_Accept_Valid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new BitcoinWorkerContext - { - Difficulty = 0.5, - ExtraNonce1 = "01000058", - }); - - var bt = JsonConvert.DeserializeObject( - "{\"Version\":536870912,\"PreviousBlockhash\":\"000000000909578519b5be7b37fdc53b2923817921c43108a907b72264da76bb\",\"CoinbaseValue\":5000000000,\"Target\":\"7fffff0000000000000000000000000000000000000000000000000000000000\",\"NonceRange\":\"00000000ffffffff\",\"CurTime\":1508869874,\"Bits\":\"207fffff\",\"Height\":14,\"Transactions\":[],\"CoinbaseAux\":{\"Flags\":\"0b2f454231362f414431322f\"},\"default_witness_commitment\":null}"); - - var job = new BitcoinJob(); - - // set clock to job creation time - var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime }; - - job.Init(bt, "1", poolConfig, null, clusterConfig, clock, poolAddressDestination, Network.RegTest, - false, 1, sha256d, sha256d, sha256dReverse); - - // set clock to submission time - clock.CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869907).UtcDateTime; - - var (share, blockHex) = job.ProcessShare(worker, "01000000", "59ef86f2", "8d84ae6a"); - - Assert.NotNull(share); - Assert.True(share.IsBlockCandidate); - Assert.Equal(share.BlockHash, "601ed85039804bcecbbdb53e0ca358aeb8dabef2366fb64c216aac3aba02b716"); - Assert.Equal(blockHex, "00000020bb76da6422b707a90831c421798123293bc5fd377bbeb5198557090900000000fd5418fe788ef961678e4bacdd1fe3903185b9ec63865bb3d2d279bb0eb48c0bf286ef59ffff7f206aae848d0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff295e0c0b2f454231362f414431322f04f286ef590001000058010000000c2f4d696e696e67436f72652f000000000100f2052a010000001976a9142ebb5cccf9a6bb927661d2953655c43c04accc3788ac00000000"); - Assert.Equal(share.BlockHeight, 14); - Assert.Equal(share.Difficulty, 0.5); - } - - [Fact] - public void BitcoinJob_Should_Not_Accept_Invalid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new BitcoinWorkerContext - { - Difficulty = 0.5, - ExtraNonce1 = "01000058", - }); - - var bt = JsonConvert.DeserializeObject( - "{\"Version\":536870912,\"PreviousBlockhash\":\"000000000909578519b5be7b37fdc53b2923817921c43108a907b72264da76bb\",\"CoinbaseValue\":5000000000,\"Target\":\"7fffff0000000000000000000000000000000000000000000000000000000000\",\"NonceRange\":\"00000000ffffffff\",\"CurTime\":1508869874,\"Bits\":\"207fffff\",\"Height\":14,\"Transactions\":[],\"CoinbaseAux\":{\"Flags\":\"0b2f454231362f414431322f\"},\"default_witness_commitment\":null}"); - - var job = new BitcoinJob(); - - // set clock to job creation time - var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime }; - - job.Init(bt, "1", poolConfig, null, clusterConfig, clock, poolAddressDestination, Network.RegTest, - false, 1, sha256d, sha256d, sha256dReverse); - - // set clock to submission time - clock.CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869907).UtcDateTime; - - // invalid extra-nonce 2 - Assert.Throws(() => job.ProcessShare(worker, "02000000", "59ef86f2", "8d84ae6a")); - - // make sure we don't accept case-sensitive duplicate shares as basically 0xdeadbeaf = 0xDEADBEAF. - var (share, blockHex) = job.ProcessShare(worker, "01000000", "59ef86f2", "8d84ae6a"); - Assert.Throws(() => job.ProcessShare(worker, "01000000", "59ef86f2", "8D84AE6A")); - - // invalid time - Assert.Throws(() => job.ProcessShare(worker, "01000000", "69ef86f2", "8d84ae6a")); - - // invalid nonce - Assert.Throws(() => job.ProcessShare(worker, "01000000", "59ef86f2", "4a84be6a")); - - // valid share data but invalid submission time - clock.CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1408869907).UtcDateTime; - Assert.Throws(() => job.ProcessShare(worker, "01000000", "59ef86f2", "8d84ae6a")); - } - } -} diff --git a/src/Miningcore.Tests/Blockchain/Cryptonote/CryptonoteJobTests.cs b/src/Miningcore.Tests/Blockchain/Cryptonote/CryptonoteJobTests.cs deleted file mode 100644 index 200120e286..0000000000 --- a/src/Miningcore.Tests/Blockchain/Cryptonote/CryptonoteJobTests.cs +++ /dev/null @@ -1,103 +0,0 @@ -using Miningcore.Blockchain.Cryptonote; -using Miningcore.Configuration; -using Miningcore.Extensions; -using Miningcore.Stratum; -using Newtonsoft.Json; -using Xunit; - -namespace Miningcore.Tests.Blockchain.Cryptonote -{ - public class CryptonoteJobTests : TestBase - { - public CryptonoteJobTests() - { - poolConfig = new PoolConfig - { - Coin = "monero", - Template = ModuleInitializer.CoinTemplates["monero"] - }; - } - - readonly PoolConfig poolConfig; - - readonly ClusterConfig clusterConfig = new ClusterConfig(); - - [Fact] - public void MoneroJob_PrepareWorkerJob() - { - var worker = new StratumClient(); - - worker.SetContext(new CryptonoteWorkerContext - { - Difficulty = 1000, - }); - - var bt = JsonConvert.DeserializeObject( - "{\"blocktemplate_blob\":\"0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c0208000000000000000000\",\"Difficulty\":2,\"Height\":224,\"prev_hash\":\"8234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d\",\"reserved_offset\":322,\"Status\":\"OK\"}"); - - var job = new CryptonoteJob(bt, "d150da".HexToByteArray(), "1", poolConfig, clusterConfig, ""); - - var workerJob = new CryptonoteWorkerJob(1.ToString(), 10000); - job.PrepareWorkerJob(workerJob, out var blob, out var target); - - Assert.Equal(blob, "0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000b7dff217012da3129b6e6a4b8705a598f8928469398b3479b711b6ceee16072301"); - Assert.Equal(target, "b88d0600"); - } - - [Fact] - public void MoneroJob_Should_Accept_Valid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new CryptonoteWorkerContext - { - Difficulty = 1000, - }); - - var bt = JsonConvert.DeserializeObject( - "{\"blocktemplate_blob\":\"0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c0208000000000000000000\",\"Difficulty\":2,\"Height\":224,\"prev_hash\":\"8234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d\",\"reserved_offset\":322,\"Status\":\"OK\"}"); - - var job = new CryptonoteJob(bt, "d150da".HexToByteArray(), "1", poolConfig, clusterConfig, ""); - var (share, blobHex) = job.ProcessShare("040100a4", 1, "f29c7fbf57d97eeedb61555857d7a34314250da20742b8157f96e0be89530a00", worker); - - Assert.NotNull(share); - Assert.True(share.IsBlockCandidate); - Assert.Equal(share.BlockHash, "9258faf2dff5daf026681b5fa5d94a34dbb5bade1d9e2070865ba8c68f8f0454"); - Assert.Equal(blobHex, "0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d040100a4019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c02080000000001d150da00"); - Assert.Equal(share.BlockHeight, 224); - Assert.Equal(share.Difficulty, 1000); - } - - [Fact] - public void MoneroJob_Should_Not_Accept_Invalid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new CryptonoteWorkerContext - { - Difficulty = 1000, - }); - - var bt = JsonConvert.DeserializeObject( - "{\"blocktemplate_blob\":\"0106e7eabdcf058234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d00000000019c0201ffe00106e3a1a0cc010275d92c0a057aa5f073079694a153d426f837f49fdb9654da10a5364e79a2086280a0d9e61d028b46dca0d04998500b40b046fd6f8bb33229e6380fd465dbb1327aa6f813d8bd80c0fc82aa0202372f076459e769116d604d30aabff7160782acc0d20e0c5cdc8963ed4e16372f8090cad2c60e02f009504ce65538bbb684b466b21be3a90e3740f185d7089d37b75f0cf62b6e7680e08d84ddcb0102cf01b85c0b592bb6e508e20b5d317052b75de121908390363201abff3476ef0180c0caf384a302024b81076c8ad0cfe84cc32fe0813d63cdd0f7d8d0e56d82aa3f58cbbe49d4c61e2b017aaf3074be7ecb30a769595758e4da7c7c87ead864baf89b679b73153dfa352c0208000000000000000000\",\"Difficulty\":2,\"Height\":224,\"prev_hash\":\"8234351e2e6ea901a56b33bb531587424321873072d80a9e97295b6c43152b9d\",\"reserved_offset\":322,\"Status\":\"OK\"}"); - - var job = new CryptonoteJob(bt, "d150da".HexToByteArray(), "1", poolConfig, clusterConfig, ""); - - // invalid nonce - Assert.Throws(() => - job.ProcessShare("040100a5", 1, "f29c7fbf57d97eeedb61555857d7a34314250da20742b8157f96e0be89530a00", worker)); - - // invalid extra-nonce - Assert.Throws(() => - job.ProcessShare("040100a4", 2, "f29c7fbf57d97eeedb61555857d7a34314250da20742b8157f96e0be89530a00", worker)); - - // invalid hash - Assert.Throws(() => - job.ProcessShare("040100a4", 1, "a29c7fbf57d97eeedb61555857d7a34314250da20742b8157f96e0be89530a00", worker)); - - // invalid hash 2 - Assert.Throws(() => - job.ProcessShare("040100a4", 1, "9c7fbf57d97eeedb61555857d7a34314250da20742b8157f96e0be89530a00", worker)); - } - } -} diff --git a/src/Miningcore.Tests/Blockchain/Equihash/EquihashJobTests.cs b/src/Miningcore.Tests/Blockchain/Equihash/EquihashJobTests.cs deleted file mode 100644 index 9044f23b69..0000000000 --- a/src/Miningcore.Tests/Blockchain/Equihash/EquihashJobTests.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using Miningcore.Blockchain.Bitcoin; -using Miningcore.Blockchain.Bitcoin.DaemonResponses; -using Miningcore.Blockchain.Equihash; -using Miningcore.Blockchain.Equihash.DaemonResponses; -using Miningcore.Configuration; -using Miningcore.Crypto; -using Miningcore.Crypto.Hashing.Algorithms; -using Miningcore.Crypto.Hashing.Equihash; -using Miningcore.Tests.Util; -using NBitcoin; -using NBitcoin.Zcash; -using Xunit; - -namespace Miningcore.Tests.Blockchain.Equihash -{ - public class EquihashJobTests : TestBase - { - public EquihashJobTests() - { - ZcashNetworks.Instance.EnsureRegistered(); - - poolConfig = new PoolConfig - { - Coin = "zcash", - Template = ModuleInitializer.CoinTemplates["zcash"] - }; - } - - readonly PoolConfig poolConfig; - - readonly ClusterConfig clusterConfig = new ClusterConfig(); - private readonly IDestination poolAddressDestination = BitcoinUtils.AddressToDestination("tmUEUSYYGQY3G5KMNkxAqkYYNfstaCsRCM5", ZcashNetworks.Instance.Mainnet); - - protected readonly IHashAlgorithm sha256d = new Sha256D(); - protected readonly IHashAlgorithm sha256dReverse = new DigestReverser(new Sha256D()); - - [Fact] - public void ZCashUtils_EncodeTarget() - { - var equihashCoin = poolConfig.Template.As(); - var chainConfig = equihashCoin.GetNetwork(ZcashNetworks.Instance.Mainnet.NetworkType); - - var result = EquihashUtils.EncodeTarget(0.5, chainConfig); - Assert.Equal(result, "0010102040810204081020408102040810204081020408102040810204080fe0"); - - result = EquihashUtils.EncodeTarget(10000, chainConfig); - Assert.Equal(result, "000000346dc5d63886594af4f0d844d013a92a305532617c1bda5119ce075e7a"); - } - - [Fact] - public void ZCashJob_Testnet_Validate_FoundersRewardAddress_At_Height() - { - var job = new EquihashJob(); - - var bt = new EquihashBlockTemplate - { - Target = "0000407f43000000000000000000000000000000000000000000000000000000", - PreviousBlockhash = "000003be5873fc64b1b784318e3226a1ab2a1805bebba5a0d670be54ff7772e8", - Bits = "003355", - Transactions = new BitcoinBlockTransaction[0], - Subsidy = new ZCashBlockSubsidy - { - Founders = 2.5m, - Miner = 10m, - } - }; - - var clock = new MockMasterClock { CurrentTime = DateTimeOffset.FromUnixTimeSeconds(1508869874).UtcDateTime }; - - var equihashCoin = poolConfig.Template.As(); - var chainConfig = equihashCoin.GetNetwork(ZcashNetworks.Instance.Mainnet.NetworkType); - var solver = EquihashSolverFactory.GetSolver(ModuleInitializer.Container, chainConfig.Solver); - - job.Init(bt, "1", poolConfig, clusterConfig, clock, poolAddressDestination, ZcashNetworks.Instance.Testnet, solver); - - bt.Height = 1; - Assert.Equal(job.GetFoundersRewardAddress(), "t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi"); - bt.Height = 53126; - Assert.Equal(job.GetFoundersRewardAddress(), "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2"); - bt.Height = 53127; - Assert.Equal(job.GetFoundersRewardAddress(), "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy"); - } - } -} diff --git a/src/Miningcore.Tests/Blockchain/Ethereum/EthereumJobTests.cs b/src/Miningcore.Tests/Blockchain/Ethereum/EthereumJobTests.cs deleted file mode 100644 index db03cb00aa..0000000000 --- a/src/Miningcore.Tests/Blockchain/Ethereum/EthereumJobTests.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.IO; -using System.Threading.Tasks; -using Miningcore.Blockchain.Ethereum; -using Miningcore.Crypto.Hashing.Ethash; -using Miningcore.Stratum; -using Newtonsoft.Json; -using Xunit; - -namespace Miningcore.Tests.Blockchain.Ethereum -{ - /// - /// These tests take ages to complete (> 10 min. on modern hardware) - /// due to the time it takes to generate the DAG for EthashFull - /// - public class EthereumJobTests : TestBase - { - static readonly EthashFull ethash = new EthashFull(3, Path.GetTempPath()); - - /* - [Fact] - public async Task EthereumJob_Should_Accept_Valid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new EthereumWorkerContext - { - Difficulty = 0.05, - ExtraNonce1 = "0003", - }); - - var bt = JsonConvert.DeserializeObject( - "{\"Height\":1939983,\"Header\":\"0x2b1dc55864dc6785ae5694b2a5c8fb301fee511262385007b69c06f6940f0ee3\",\"Seed\":\"0x4220f7b47dc9e1f91e2d7c117a12e9158ce7a78185c805d21338759838f6f55d\",\"Target\":5547597442670231301113464668059123372289016956050714228028458602362,\"ParentHash\":\"0x372c7825b893281707dfc7676321fb237eef771fef724f70847c8085005f7627\",\"Difficulty\":20872475055}"); - - var job = new EthereumJob("00000062", bt); - var share = await job.ProcessShareAsync(worker, "000009f3003a", ethash); - - Assert.NotNull(share); - Assert.True(share.IsBlockCandidate); - Assert.Equal(share.TransactionConfirmationData, "0xbaa8dfa217eca2af764164cbb2e1112663ffac64940cc237d8a884500f62b3a2:0x0003000009f3003a"); - Assert.Equal(share.BlockHeight, 1939983); - Assert.Equal(share.Difficulty, 214748364.8); - } - - [Fact] - public async Task EthereumJob_Should_Not_Accept_Invalid_Share() - { - var worker = new StratumClient(); - - worker.SetContext(new EthereumWorkerContext - { - Difficulty = 0.05, - ExtraNonce1 = "0003", - }); - - var bt = JsonConvert.DeserializeObject( - "{\"Height\":1939983,\"Header\":\"0x2b1dc55864dc6785ae5694b2a5c8fb301fee511262385007b69c06f6940f0ee3\",\"Seed\":\"0x4220f7b47dc9e1f91e2d7c117a12e9158ce7a78185c805d21338759838f6f55d\",\"Target\":5547597442670231301113464668059123372289016956050714228028458602362,\"ParentHash\":\"0x372c7825b893281707dfc7676321fb237eef771fef724f70847c8085005f7627\",\"Difficulty\":20872475055}"); - - var job = new EthereumJob("00000062", bt); - - // invalid nonce - await Assert.ThrowsAsync(() => job.ProcessShareAsync(worker, "00000af3003a", ethash)); - - // invalid extra-nonce - worker.GetContextAs().ExtraNonce1 = "0001"; - await Assert.ThrowsAsync(() => job.ProcessShareAsync(worker, "000009f3003a", ethash)); - } - */ - } -} diff --git a/src/Miningcore.Tests/Crypto/CrytonoteTests.cs b/src/Miningcore.Tests/Crypto/CrytonoteTests.cs index 939738d3bd..e9c21d4edb 100644 --- a/src/Miningcore.Tests/Crypto/CrytonoteTests.cs +++ b/src/Miningcore.Tests/Crypto/CrytonoteTests.cs @@ -1,143 +1,13 @@ using System; +using System.Text; using Miningcore.Extensions; using Miningcore.Native; using Xunit; -using static Miningcore.Native.LibCryptonight; namespace Miningcore.Tests.Crypto { public class CrytonoteTests : TestBase { - [Fact] - public void Crytonight() - { - var blobConverted = "0106a2aaafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42580100a4b1e2f4baf6ab7109071ab59bc52dba740d1de99fa0ae0c4afd6ea9f40c5d87ec01".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - var result = buf.ToHexString(); - Assert.Equal("a845ffbdf83ae9a8ffa504a1011efbd5ed2294bb9da591d3b583740568402c00", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - result = buf.ToHexString(); - Assert.Equal("a845ffbdf83ae9a8ffa504a1011efbd5ed2294bb9da591d3b583740568402c00", result); - } - - [Fact] - public void Crytonight_Variant_1() - { - var blobConverted = "0106a2aaafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42580100a4b1e2f4baf6ab7109071ab59bc52dba740d1de99fa0ae0c4afd6ea9f40c5d87ec01".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_1, 0); - var result = buf.ToHexString(); - Assert.Equal("c41ec6434df8b2307ff3105ae15206f3fbdf5a99b35879c0a27b8b85a8e2704f", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_1, 0); - result = buf.ToHexString(); - Assert.Equal("c41ec6434df8b2307ff3105ae15206f3fbdf5a99b35879c0a27b8b85a8e2704f", result); - } - - [Fact] - public void Crytonight_Variant_4() - { - var blobConverted = "0106a2aaafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42580100a4b1e2f4baf6ab7109071ab59bc52dba740d1de99fa0ae0c4afd6ea9f40c5d87ec01".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_4, 0); - var result = buf.ToHexString(); - Assert.Equal("3e69817268c70010f793d53ba1a9f12af21753c723c7d7990a8eefccc6d163ba", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.Cryptonight(blobConverted, buf, CryptonightVariant.VARIANT_4, 0); - result = buf.ToHexString(); - Assert.Equal("3e69817268c70010f793d53ba1a9f12af21753c723c7d7990a8eefccc6d163ba", result); - } - - [Fact] - public void Crytonote_Hash_Fast() - { - var blobConverted = "0106a2aaafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42580100a4b1e2f4baf6ab7109071ab59bc52dba740d1de99fa0ae0c4afd6ea9f40c5d87ec01".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonote.CryptonightHashFast(blobConverted, buf); - var result = buf.ToHexString(); - Assert.Equal("ddc0e3a33b605ce39fa2d16a98d7634e33399ab1e4b56b3bdd3414b655fe9a98", result); - } - - [Fact] - public void Crytonight_Light() - { - var blobConverted = "0106f1adafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42597710c48c6d885e2622f40f82ecd9b9fd538f28df9b0557e07cd3237a31c76569ada98001".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.CryptonightLight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - var result = buf.ToHexString(); - Assert.Equal("0769caee428a232cffb76fa200f174ff962734f24e7b3bf8d1b0d4e8ba6ceebf", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.CryptonightLight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - result = buf.ToHexString(); - Assert.Equal("0769caee428a232cffb76fa200f174ff962734f24e7b3bf8d1b0d4e8ba6ceebf", result); - } - - [Fact] - public void Crytonight_Light_Variant_1() - { - var blobConverted = "0106f1adafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42597710c48c6d885e2622f40f82ecd9b9fd538f28df9b0557e07cd3237a31c76569ada98001".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.CryptonightLight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - var result = buf.ToHexString(); - Assert.Equal("0769caee428a232cffb76fa200f174ff962734f24e7b3bf8d1b0d4e8ba6ceebf", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.CryptonightLight(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - result = buf.ToHexString(); - Assert.Equal("0769caee428a232cffb76fa200f174ff962734f24e7b3bf8d1b0d4e8ba6ceebf", result); - } - - [Fact] - public void Crytonight_Heavy() - { - var blobConverted = "0106f1adafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42597710c48c6d885e2622f40f82ecd9b9fd538f28df9b0557e07cd3237a31c76569ada98001".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.CryptonightHeavy(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - var result = buf.ToHexString(); - Assert.Equal("93b6815d8f19abe0ff8ba8d8cf951cd264aa123e450bd52dc806fac298f83d9f", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.CryptonightHeavy(blobConverted, buf, CryptonightVariant.VARIANT_0, 0); - result = buf.ToHexString(); - Assert.Equal("93b6815d8f19abe0ff8ba8d8cf951cd264aa123e450bd52dc806fac298f83d9f", result); - } - - [Fact] - public void Crytonight_Heavy_Variant_1() - { - var blobConverted = "0106f1adafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42597710c48c6d885e2622f40f82ecd9b9fd538f28df9b0557e07cd3237a31c76569ada98001".HexToByteArray(); - var buf = new byte[32]; - - LibCryptonight.CryptonightHeavy(blobConverted, buf, CryptonightVariant.VARIANT_1, 0); - var result = buf.ToHexString(); - Assert.Equal("342418ec4bf806aafb102b34d64fc33ab91d89ad40786b92d1b54ceeb4d50822", result); - - Array.Clear(buf, 0, buf.Length); - - LibCryptonight.CryptonightHeavy(blobConverted, buf, CryptonightVariant.VARIANT_1, 0); - result = buf.ToHexString(); - Assert.Equal("342418ec4bf806aafb102b34d64fc33ab91d89ad40786b92d1b54ceeb4d50822", result); - } - [Fact] public void Crytonote_ConvertBlob() { diff --git a/src/Miningcore.Tests/Crypto/HashingTests.cs b/src/Miningcore.Tests/Crypto/HashingTests.cs index f311cf8d76..f76e9e2949 100644 --- a/src/Miningcore.Tests/Crypto/HashingTests.cs +++ b/src/Miningcore.Tests/Crypto/HashingTests.cs @@ -2,9 +2,12 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using System.Runtime.InteropServices; +using System.Text; using Miningcore.Crypto.Hashing.Algorithms; using Miningcore.Crypto.Hashing.Equihash; using Miningcore.Extensions; +using Miningcore.Native; using Miningcore.Tests.Util; using Xunit; using static Miningcore.Configuration.BitcoinTemplate; @@ -234,34 +237,25 @@ public void X21S_Hash() } [Fact] - public void X25X_Hash() + public void X22I_Hash() { - var hasher = new X25X(); + var hasher = new X22I(); var hash = new byte[32]; hasher.Digest(testValue, hash); var result = hash.ToHexString(); - Assert.Equal("fe2a3d0e45eb5afbf007055c2605590db4167169dc03d1d5a070885771e51846", result); + Assert.Equal("616c341e79417e6623dacff834c5c480d8d7d43ba6ae60fcee99f69343fd7c99", result); } [Fact] - public void Odocrypt_Hash() + public void X25X_Hash() { - var hasher = new OdoCrypt(); + var hasher = new X25X(); var hash = new byte[32]; - - var bnp = new BitcoinNetworkParams - { - Extra = new Dictionary - { - [nameof(OdoCryptConfig.OdoCryptShapeChangeInterval)] = 864000 - } - }; - - hasher.Digest(testValue2, hash, (ulong) 0x59ef86f2, null, null, bnp); + hasher.Digest(testValue, hash); var result = hash.ToHexString(); - Assert.Equal("93164a82a79fba784dcf04c0b0f8537cc43821e7518bf513f296de50aefee4cf", result); + Assert.Equal("fe2a3d0e45eb5afbf007055c2605590db4167169dc03d1d5a070885771e51846", result); } [Fact] @@ -370,5 +364,23 @@ public void Sha3_512_Hash() Assert.Equal("e0883cffc9ff0ecf41fca8ade29dba1fc0df4b15beccc06ca03283805e176e497f0dd33db3bda375b199a4bb5eb1bb3ba884f3cc26f65f7acf08e1307058cc8d", result); } + + [Fact] + public void RandomX() + { + var blobConverted = "0106a2aaafd505583cf50bcc743d04d831d2b119dc94ad88679e359076ee3f18d258ee138b3b42580100a4b1e2f4baf6ab7109071ab59bc52dba740d1de99fa0ae0c4afd6ea9f40c5d87ec01".HexToByteArray(); + var buf = new byte[32]; + var key = Encoding.UTF8.GetBytes("foo bar"); + + LibRandomX.CalculateHash(key, blobConverted, buf); + var result = buf.ToHexString(); + Assert.Equal("ae46586e2b786b08cf3884747e391fc27695b40c2502b45b39727832099a19c0", result); + + Array.Clear(buf, 0, buf.Length); + + LibRandomX.CalculateHash(key, blobConverted, buf); + result = buf.ToHexString(); + Assert.Equal("ae46586e2b786b08cf3884747e391fc27695b40c2502b45b39727832099a19c0", result); + } } } diff --git a/src/Miningcore.Tests/Miningcore.Tests.csproj b/src/Miningcore.Tests/Miningcore.Tests.csproj index 2ea5169a26..67ec55d299 100644 --- a/src/Miningcore.Tests/Miningcore.Tests.csproj +++ b/src/Miningcore.Tests/Miningcore.Tests.csproj @@ -10,7 +10,7 @@ - netcoreapp2.2 + net5.0 false AnyCPU Miningcore.Tests @@ -33,11 +33,10 @@ - - - + + - + all runtime; build; native; contentfiles; analyzers @@ -48,6 +47,9 @@ + + Always + PreserveNewest diff --git a/src/Miningcore.Tests/xunit.runner.json b/src/Miningcore.Tests/xunit.runner.json index c3b4c82887..1d28022055 100644 --- a/src/Miningcore.Tests/xunit.runner.json +++ b/src/Miningcore.Tests/xunit.runner.json @@ -1,3 +1,3 @@ -{ +{ "methodDisplay": "method" -} \ No newline at end of file +} diff --git a/src/Miningcore/Api/Controllers/AdminApiController.cs b/src/Miningcore/Api/Controllers/AdminApiController.cs index aa99b97a86..b06da9f0f5 100644 --- a/src/Miningcore/Api/Controllers/AdminApiController.cs +++ b/src/Miningcore/Api/Controllers/AdminApiController.cs @@ -34,7 +34,7 @@ public AdminApiController(IComponentContext ctx) private readonly IBalanceRepository balanceRepo; private readonly ConcurrentDictionary pools; - private AdminGcStats gcStats; + private readonly AdminGcStats gcStats; #region Actions diff --git a/src/Miningcore/Api/Controllers/PoolApiController.cs b/src/Miningcore/Api/Controllers/PoolApiController.cs index 8dca345443..a1a2764744 100644 --- a/src/Miningcore/Api/Controllers/PoolApiController.cs +++ b/src/Miningcore/Api/Controllers/PoolApiController.cs @@ -1,6 +1,7 @@ using Autofac; using AutoMapper; using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Infrastructure; using Miningcore.Api.Extensions; using Miningcore.Api.Responses; using Miningcore.Blockchain; @@ -14,11 +15,13 @@ using Miningcore.Time; using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Data; using System.Globalization; using System.Linq; using System.Net; using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc.ActionConstraints; namespace Miningcore.Api.Controllers { @@ -26,7 +29,7 @@ namespace Miningcore.Api.Controllers [ApiController] public class PoolApiController : ControllerBase { - public PoolApiController(IComponentContext ctx) + public PoolApiController(IComponentContext ctx, IActionDescriptorCollectionProvider _adcp) { clusterConfig = ctx.Resolve(); cf = ctx.Resolve(); @@ -36,6 +39,7 @@ public PoolApiController(IComponentContext ctx) mapper = ctx.Resolve(); clock = ctx.Resolve(); pools = ctx.Resolve>(); + adcp = _adcp; } private readonly ClusterConfig clusterConfig; @@ -45,6 +49,7 @@ public PoolApiController(IComponentContext ctx) private readonly IPaymentRepository paymentsRepo; private readonly IMapper mapper; private readonly IMasterClock clock; + private readonly IActionDescriptorCollectionProvider adcp; private readonly ConcurrentDictionary pools; #region Actions @@ -67,12 +72,14 @@ public async Task Get() // enrich result.TotalPaid = await cf.Run(con => statsRepo.GetTotalPoolPaymentsAsync(con, config.Id)); + result.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, config.Id)); + result.LastPoolBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, config.Id)); + var from = clock.Now.AddDays(-1); - result.TopMiners = (await cf.Run(con => statsRepo.PagePoolMinersByHashrateAsync( - con, config.Id, from, 0, 15))) - .Select(mapper.Map) - .ToArray(); + var minersByHashrate = await cf.Run(con => statsRepo.PagePoolMinersByHashrateAsync(con, config.Id, from, 0, 15)); + + result.TopMiners = minersByHashrate.Select(mapper.Map).ToArray(); return result; }).ToArray()) @@ -81,6 +88,25 @@ public async Task Get() return response; } + [HttpGet("/api/help")] + public ActionResult GetHelp() + { + var tmp = adcp.ActionDescriptors.Items + .Select(x => + { + // Get and pad http method + var method = x?.ActionConstraints?.OfType().FirstOrDefault()?.HttpMethods.First(); + method = $"{method,-5}"; + + return $"{method} -> {x.AttributeRouteInfo.Template}"; + }); + + // convert curly braces + var result = string.Join("\n", tmp).Replace("{", "<").Replace("}", ">") + "\n"; + + return Content(result); + } + [HttpGet("{poolId}")] public async Task GetPoolInfoAsync(string poolId) { @@ -99,6 +125,8 @@ public async Task GetPoolInfoAsync(string poolId) // enrich response.Pool.TotalPaid = await cf.Run(con => statsRepo.GetTotalPoolPaymentsAsync(con, pool.Id)); + response.Pool.TotalBlocks = await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, pool.Id)); + response.Pool.LastPoolBlockTime = await cf.Run(con => blocksRepo.GetLastPoolBlockTimeAsync(con, pool.Id)); var from = clock.Now.AddDays(-1); @@ -165,7 +193,7 @@ public async Task PagePoolMinersAsync( } [HttpGet("{poolId}/blocks")] - public async Task PagePoolBlocksPagedAsync( + public async Task PagePoolBlocksAsync( string poolId, [FromQuery] int page, [FromQuery] int pageSize = 15, [FromQuery] BlockStatus[] state = null) { var pool = GetPool(poolId); @@ -201,6 +229,46 @@ public async Task PagePoolMinersAsync( return blocks; } + [HttpGet("/api/v2/pools/{poolId}/blocks")] + public async Task> PagePoolBlocksV2Async( + string poolId, [FromQuery] int page, [FromQuery] int pageSize = 15, [FromQuery] BlockStatus[] state = null) + { + var pool = GetPool(poolId); + + var blockStates = state != null && state.Length > 0 ? + state : + new[] { BlockStatus.Confirmed, BlockStatus.Pending, BlockStatus.Orphaned }; + + uint pageCount = (uint) Math.Floor((await cf.Run(con => blocksRepo.GetPoolBlockCountAsync(con, poolId))) / (double) pageSize); + + var blocks = (await cf.Run(con => blocksRepo.PageBlocksAsync(con, pool.Id, blockStates, page, pageSize))) + .Select(mapper.Map) + .ToArray(); + + // enrich blocks + var blockInfobaseDict = pool.Template.ExplorerBlockLinks; + + foreach(var block in blocks) + { + // compute infoLink + if(blockInfobaseDict != null) + { + blockInfobaseDict.TryGetValue(!string.IsNullOrEmpty(block.Type) ? block.Type : "block", out var blockInfobaseUrl); + + if(!string.IsNullOrEmpty(blockInfobaseUrl)) + { + if(blockInfobaseUrl.Contains(CoinMetaData.BlockHeightPH)) + block.InfoLink = blockInfobaseUrl.Replace(CoinMetaData.BlockHeightPH, block.BlockHeight.ToString(CultureInfo.InvariantCulture)); + else if(blockInfobaseUrl.Contains(CoinMetaData.BlockHashPH) && !string.IsNullOrEmpty(block.Hash)) + block.InfoLink = blockInfobaseUrl.Replace(CoinMetaData.BlockHashPH, block.Hash); + } + } + } + + var response = new PagedResultResponse(blocks, pageCount); + return response; + } + [HttpGet("{poolId}/payments")] public async Task PagePoolPaymentsAsync( string poolId, [FromQuery] int page, [FromQuery] int pageSize = 15) @@ -230,6 +298,38 @@ public async Task PagePoolMinersAsync( return payments; } + [HttpGet("/api/v2/pools/{poolId}/payments")] + public async Task> PagePoolPaymentsV2Async( + string poolId, [FromQuery] int page, [FromQuery] int pageSize = 15) + { + var pool = GetPool(poolId); + + uint pageCount = (uint) Math.Floor((await cf.Run(con => paymentsRepo.GetPaymentsCountAsync(con, poolId))) / (double) pageSize); + + var payments = (await cf.Run(con => paymentsRepo.PagePaymentsAsync( + con, pool.Id, null, page, pageSize))) + .Select(mapper.Map) + .ToArray(); + + // enrich payments + var txInfobaseUrl = pool.Template.ExplorerTxLink; + var addressInfobaseUrl = pool.Template.ExplorerAccountLink; + + foreach(var payment in payments) + { + // compute transaction infoLink + if(!string.IsNullOrEmpty(txInfobaseUrl)) + payment.TransactionInfoLink = string.Format(txInfobaseUrl, payment.TransactionConfirmationData); + + // pool wallet link + if(!string.IsNullOrEmpty(addressInfobaseUrl)) + payment.AddressInfoLink = string.Format(addressInfobaseUrl, payment.Address); + } + + var response = new PagedResultResponse(payments, pageCount); + return response; + } + [HttpGet("{poolId}/miners/{address}")] public async Task GetMinerInfoAsync( string poolId, string address, [FromQuery] SampleRange perfMode = SampleRange.Day) @@ -298,6 +398,41 @@ public async Task PagePoolMinersAsync( return payments; } + [HttpGet("/api/v2/pools/{poolId}/miners/{address}/payments")] + public async Task> PageMinerPaymentsV2Async( + string poolId, string address, [FromQuery] int page, [FromQuery] int pageSize = 15) + { + var pool = GetPool(poolId); + + if(string.IsNullOrEmpty(address)) + throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); + + uint pageCount = (uint) Math.Floor((await cf.Run(con => paymentsRepo.GetPaymentsCountAsync(con, poolId, address))) / (double) pageSize); + + var payments = (await cf.Run(con => paymentsRepo.PagePaymentsAsync( + con, pool.Id, address, page, pageSize))) + .Select(mapper.Map) + .ToArray(); + + // enrich payments + var txInfobaseUrl = pool.Template.ExplorerTxLink; + var addressInfobaseUrl = pool.Template.ExplorerAccountLink; + + foreach(var payment in payments) + { + // compute transaction infoLink + if(!string.IsNullOrEmpty(txInfobaseUrl)) + payment.TransactionInfoLink = string.Format(txInfobaseUrl, payment.TransactionConfirmationData); + + // pool wallet link + if(!string.IsNullOrEmpty(addressInfobaseUrl)) + payment.AddressInfoLink = string.Format(addressInfobaseUrl, payment.Address); + } + + var response = new PagedResultResponse(payments, pageCount); + return response; + } + [HttpGet("{poolId}/miners/{address}/balancechanges")] public async Task PageMinerBalanceChangesAsync( string poolId, string address, [FromQuery] int page, [FromQuery] int pageSize = 15) @@ -315,6 +450,26 @@ public async Task PagePoolMinersAsync( return balanceChanges; } + [HttpGet("/api/v2/pools/{poolId}/miners/{address}/balancechanges")] + public async Task> PageMinerBalanceChangesV2Async( + string poolId, string address, [FromQuery] int page, [FromQuery] int pageSize = 15) + { + var pool = GetPool(poolId); + + if(string.IsNullOrEmpty(address)) + throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); + + uint pageCount = (uint) Math.Floor((await cf.Run(con => paymentsRepo.GetBalanceChangesCountAsync(con, poolId, address))) / (double) pageSize); + + var balanceChanges = (await cf.Run(con => paymentsRepo.PageBalanceChangesAsync( + con, pool.Id, address, page, pageSize))) + .Select(mapper.Map) + .ToArray(); + + var response = new PagedResultResponse(balanceChanges, pageCount); + return response; + } + [HttpGet("{poolId}/miners/{address}/earnings/daily")] public async Task PageMinerEarningsByDayAsync( string poolId, string address, [FromQuery] int page, [FromQuery] int pageSize = 15) @@ -331,6 +486,25 @@ public async Task PageMinerEarningsByDayAsync( return earnings; } + [HttpGet("/api/v2/pools/{poolId}/miners/{address}/earnings/daily")] + public async Task> PageMinerEarningsByDayV2Async( + string poolId, string address, [FromQuery] int page, [FromQuery] int pageSize = 15) + { + var pool = GetPool(poolId); + + if(string.IsNullOrEmpty(address)) + throw new ApiException($"Invalid or missing miner address", HttpStatusCode.NotFound); + + uint pageCount = (uint) Math.Floor((await cf.Run(con => paymentsRepo.GetMinerPaymentsByDayCountAsync(con, poolId, address))) / (double) pageSize); + + var earnings = (await cf.Run(con => paymentsRepo.PageMinerPaymentsByDayAsync( + con, pool.Id, address, page, pageSize))) + .ToArray(); + + var response = new PagedResultResponse(earnings, pageCount); + return response; + } + [HttpGet("{poolId}/miners/{address}/performance")] public async Task GetMinerPerformanceAsync( string poolId, string address, [FromQuery] SampleRange mode = SampleRange.Day) diff --git a/src/Miningcore/Api/Extensions/MiningPoolExtensions.cs b/src/Miningcore/Api/Extensions/MiningPoolExtensions.cs index 6c5c3cc757..24e9bf27bd 100644 --- a/src/Miningcore/Api/Extensions/MiningPoolExtensions.cs +++ b/src/Miningcore/Api/Extensions/MiningPoolExtensions.cs @@ -1,9 +1,7 @@ using System.Linq; -using Autofac; using AutoMapper; using Miningcore.Api.Responses; using Miningcore.Blockchain; -using Miningcore.Blockchain.Ethereum.Configuration; using Miningcore.Configuration; using Miningcore.Extensions; using Miningcore.Mining; @@ -25,14 +23,14 @@ public static PoolInfo ToPoolInfo(this PoolConfig poolConfig, IMapper mapper, Pe poolInfo.AddressInfoLink = string.Format(addressInfobaseUrl, poolInfo.Address); // pool fees - poolInfo.PoolFeePercent = (float) poolConfig.RewardRecipients.Sum(x => x.Percentage); + poolInfo.PoolFeePercent = poolConfig.RewardRecipients != null ? (float) poolConfig.RewardRecipients.Sum(x => x.Percentage) : 0; // strip security critical stuff if(poolInfo.PaymentProcessing.Extra != null) { var extra = poolInfo.PaymentProcessing.Extra; - extra.StripValue(nameof(EthereumPoolPaymentProcessingConfigExtra.CoinbasePassword)); + //extra.StripValue(nameof(EthereumPoolPaymentProcessingConfigExtra.CoinbasePassword)); } return poolInfo; diff --git a/src/Miningcore/Api/Responses/GetPoolsResponse.cs b/src/Miningcore/Api/Responses/GetPoolsResponse.cs index f72c1b4869..dfdf567fbc 100644 --- a/src/Miningcore/Api/Responses/GetPoolsResponse.cs +++ b/src/Miningcore/Api/Responses/GetPoolsResponse.cs @@ -18,6 +18,7 @@ portions of the Software. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +using System; using System.Collections.Generic; using Miningcore.Blockchain; using Miningcore.Configuration; @@ -31,6 +32,7 @@ public class ApiCoinConfig { public string Type { get; set; } public string Name { get; set; } + public string Symbol { get; set; } public string Family { get; set; } public string Algorithm { get; set; } @@ -71,6 +73,8 @@ public partial class PoolInfo public BlockchainStats NetworkStats { get; set; } public MinerPerformanceStats[] TopMiners { get; set; } public decimal TotalPaid { get; set; } + public uint TotalBlocks { get; set; } + public DateTime? LastPoolBlockTime { get; set; } } public class GetPoolsResponse diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/Web3VersionResponse.cs b/src/Miningcore/Api/Responses/PagedResultResponse.cs similarity index 77% rename from src/Miningcore/Blockchain/Ethereum/DaemonResponses/Web3VersionResponse.cs rename to src/Miningcore/Api/Responses/PagedResultResponse.cs index ee37a24c99..57fe485d02 100644 --- a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/Web3VersionResponse.cs +++ b/src/Miningcore/Api/Responses/PagedResultResponse.cs @@ -18,17 +18,15 @@ portions of the Software. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -using System.Numerics; -using Miningcore.Serialization; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum.DaemonResponses +namespace Miningcore.Api.Responses { - public class Web3Version + public class PagedResultResponse : ResultResponse { - public string Api { get; set; } - public uint Ethereum { get; set; } - public uint Network { get; set; } - public string Node { get; set; } + public PagedResultResponse(T result, uint pageCount) : base(result) + { + PageCount = pageCount; + } + + public uint PageCount { get; private set; } } } diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumWorkerContext.cs b/src/Miningcore/Api/Responses/ResultResponse.cs similarity index 68% rename from src/Miningcore/Blockchain/Ethereum/EthereumWorkerContext.cs rename to src/Miningcore/Api/Responses/ResultResponse.cs index 9909fe6d31..e4288031be 100644 --- a/src/Miningcore/Blockchain/Ethereum/EthereumWorkerContext.cs +++ b/src/Miningcore/Api/Responses/ResultResponse.cs @@ -18,24 +18,24 @@ portions of the Software. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -using Miningcore.Mining; +using System; -namespace Miningcore.Blockchain.Ethereum +namespace Miningcore.Api.Responses { - public class EthereumWorkerContext : WorkerContextBase + public class ResultResponse { - /// - /// Usually a wallet address - /// - public string Miner { get; set; } - - /// - /// Arbitrary worker identififer for miners using multiple rigs - /// - public string Worker { get; set; } - - public bool IsInitialWorkSent { get; set; } = false; - - public string ExtraNonce1 { get; set; } + public ResultResponse(T result) + { + Result = result; + Success = result != null; + } + + public ResultResponse() + { + Success = true; + } + + public T Result { get; set; } + public bool Success { get; set; } } } diff --git a/src/Miningcore/Api/WebSocketNotifications/WebSocketNotificationsRelay.cs b/src/Miningcore/Api/WebSocketNotifications/WebSocketNotificationsRelay.cs index ffb4f7a0a5..8f7ab1eef6 100644 --- a/src/Miningcore/Api/WebSocketNotifications/WebSocketNotificationsRelay.cs +++ b/src/Miningcore/Api/WebSocketNotifications/WebSocketNotificationsRelay.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net.WebSockets; @@ -41,11 +41,11 @@ public WebSocketNotificationsRelay(WebSocketConnectionManager webSocketConnectio Relay(WsNotificationType.HashrateUpdated); } - private IMessageBus messageBus; + private readonly IMessageBus messageBus; private readonly ClusterConfig clusterConfig; private readonly Dictionary pools; - private JsonSerializer serializer; - private static ILogger logger = LogManager.GetCurrentClassLogger(); + private readonly JsonSerializer serializer; + private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); public override async Task OnConnected(WebSocket socket) { diff --git a/src/Miningcore/AutoMapperProfile.cs b/src/Miningcore/AutoMapperProfile.cs index 9527072193..99ab0be321 100644 --- a/src/Miningcore/AutoMapperProfile.cs +++ b/src/Miningcore/AutoMapperProfile.cs @@ -58,6 +58,7 @@ public AutoMapperProfile() CreateMap() .ForMember(dest => dest.Type, opt => opt.MapFrom(src => src.Symbol)) .ForMember(dest => dest.Family, opt => opt.MapFrom(src => src.Family.ToString().ToLower())) + .ForMember(dest => dest.Symbol, opt => opt.MapFrom(src => src.Symbol)) .ForMember(dest => dest.Algorithm, opt => opt.MapFrom(src => src.GetAlgorithmName())); CreateMap() @@ -76,6 +77,7 @@ public AutoMapperProfile() CreateMap(); CreateMap(); + CreateMap(); // PostgreSQL CreateMap(); diff --git a/src/Miningcore/AutofacModule.cs b/src/Miningcore/AutofacModule.cs index ad0dfb520f..8de48bbb0e 100644 --- a/src/Miningcore/AutofacModule.cs +++ b/src/Miningcore/AutofacModule.cs @@ -24,11 +24,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Miningcore.Api; using Miningcore.Banning; using Miningcore.Blockchain.Bitcoin; -using Miningcore.Blockchain.Bitcoin.DaemonResponses; -using Miningcore.Blockchain.Ethereum; using Miningcore.Blockchain.Cryptonote; using Miningcore.Blockchain.Equihash; -using Miningcore.Blockchain.Equihash.DaemonResponses; using Miningcore.Configuration; using Miningcore.Crypto; using Miningcore.Crypto.Hashing.Equihash; @@ -42,7 +39,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Newtonsoft.Json.Serialization; using Module = Autofac.Module; using Microsoft.AspNetCore.Mvc; -using Miningcore.Api.WebSocketNotifications; namespace Miningcore { @@ -153,12 +149,6 @@ protected override void Load(ContainerBuilder builder) builder.RegisterType() .AsSelf(); - ////////////////////// - // Ethereum - - builder.RegisterType() - .AsSelf(); - ////////////////////// // ZCash diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinConstants.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinConstants.cs index c7c5533065..0a7fe13ae2 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinConstants.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinConstants.cs @@ -35,6 +35,11 @@ public enum BitcoinAddressType /// Bech encoded, segwit /// BechSegwit, + + /// + /// Bitcoin Cash + /// + BCash, } public enum BitcoinTransactionCategory diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs index 1f1e617e47..53a46e5df2 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinJob.cs @@ -19,6 +19,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Globalization; using System.IO; @@ -57,7 +58,7 @@ public class BitcoinJob protected PoolConfig poolConfig; protected BitcoinTemplate coin; private BitcoinTemplate.BitcoinNetworkParams networkParams; - protected readonly HashSet submissions = new HashSet(StringComparer.OrdinalIgnoreCase); + protected readonly ConcurrentDictionary submissions = new(StringComparer.OrdinalIgnoreCase); protected uint256 blockTargetValue; protected byte[] coinbaseFinal; protected string coinbaseFinalHex; @@ -112,9 +113,7 @@ protected virtual void BuildCoinbase() scriptSigFinalBytes.Length); // output transaction - txOut = coin.HasMasterNodes ? - CreateMasternodeOutputTransaction() : - (coin.HasPayee ? CreatePayeeOutputTransaction() : CreateOutputTransaction()); + txOut = CreateOutputTransaction(); // build coinbase initial using(var stream = new MemoryStream()) @@ -246,7 +245,7 @@ protected virtual Script GenerateScriptSigInitial() ops.Add(Op.GetPushOp(BlockTemplate.Height)); // optionally push aux-flags - if(!string.IsNullOrEmpty(BlockTemplate.CoinbaseAux?.Flags)) + if(!coin.CoinbaseIgnoreAuxFlags && !string.IsNullOrEmpty(BlockTemplate.CoinbaseAux?.Flags)) ops.Add(Op.GetPushOp(BlockTemplate.CoinbaseAux.Flags.HexToByteArray())); // push timestamp @@ -261,50 +260,43 @@ protected virtual Script GenerateScriptSigInitial() protected virtual Transaction CreateOutputTransaction() { rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi); - var tx = Transaction.Create(network); + if(coin.HasPayee) + rewardToPool = CreatePayeeOutput(tx, rewardToPool); + + if(coin.HasMasterNodes) + rewardToPool = CreateMasternodeOutputs(tx, rewardToPool); + + // Remaining amount goes to pool tx.Outputs.Add(rewardToPool, poolAddressDestination); return tx; } - protected virtual Transaction CreatePayeeOutputTransaction() + protected virtual Money CreatePayeeOutput(Transaction tx, Money reward) { - rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi); - - var tx = Transaction.Create(network); - - if(payeeParameters?.PayeeAmount > 0) + if(payeeParameters?.PayeeAmount != null && payeeParameters.PayeeAmount.Value > 0) { var payeeReward = new Money(payeeParameters.PayeeAmount.Value, MoneyUnit.Satoshi); - rewardToPool -= payeeReward; + reward -= payeeReward; tx.Outputs.Add(payeeReward, BitcoinUtils.AddressToDestination(payeeParameters.Payee, network)); } - tx.Outputs.Insert(0, new TxOut(rewardToPool, poolAddressDestination)); - - return tx; + return reward; } protected bool RegisterSubmit(string extraNonce1, string extraNonce2, string nTime, string nonce) { var key = new StringBuilder() .Append(extraNonce1) - .Append(extraNonce2.ToLower()) // lowercase as we don't want to accept case-sensitive values as valid. + .Append(extraNonce2) // lowercase as we don't want to accept case-sensitive values as valid. .Append(nTime) - .Append(nonce.ToLower()) // lowercase as we don't want to accept case-sensitive values as valid. + .Append(nonce) // lowercase as we don't want to accept case-sensitive values as valid. .ToString(); - lock(submissions) - { - if(submissions.Contains(key)) - return false; - - submissions.Add(key); - return true; - } + return submissions.TryAdd(key, true); } protected byte[] SerializeHeader(Span coinbaseHash, uint nTime, uint nonce, uint? versionMask, uint? versionBits) @@ -458,22 +450,6 @@ protected virtual byte[] BuildRawTransactionBuffer() protected MasterNodeBlockTemplateExtra masterNodeParameters; - protected virtual Transaction CreateMasternodeOutputTransaction() - { - var blockReward = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi); - rewardToPool = new Money(BlockTemplate.CoinbaseValue, MoneyUnit.Satoshi); - - var tx = Transaction.Create(network); - - // outputs - rewardToPool = CreateMasternodeOutputs(tx, blockReward); - - // Finally distribute remaining funds to pool - tx.Outputs.Insert(0, new TxOut(rewardToPool, poolAddressDestination)); - - return tx; - } - protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward) { if(masterNodeParameters.Masternode != null) @@ -490,13 +466,11 @@ protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward) { if(!string.IsNullOrEmpty(masterNode.Payee)) { - var payeeAddress = BitcoinUtils.AddressToDestination(masterNode.Payee, network); + var payeeDestination = BitcoinUtils.AddressToDestination(masterNode.Payee, network); var payeeReward = masterNode.Amount; - reward -= payeeReward; - rewardToPool -= payeeReward; - tx.Outputs.Add(payeeReward, payeeAddress); + tx.Outputs.Add(payeeReward, payeeDestination); } } } @@ -507,21 +481,18 @@ protected virtual Money CreateMasternodeOutputs(Transaction tx, Money reward) { var payeeAddress = BitcoinUtils.AddressToDestination(superBlock.Payee, network); var payeeReward = superBlock.Amount; - reward -= payeeReward; - rewardToPool -= payeeReward; tx.Outputs.Add(payeeReward, payeeAddress); } } - if(!string.IsNullOrEmpty(masterNodeParameters.Payee)) + if(!coin.HasPayee && !string.IsNullOrEmpty(masterNodeParameters.Payee)) { var payeeAddress = BitcoinUtils.AddressToDestination(masterNodeParameters.Payee, network); var payeeReward = masterNodeParameters.PayeeAmount ?? (reward / 5); reward -= payeeReward; - rewardToPool -= payeeReward; tx.Outputs.Add(payeeReward, payeeAddress); } @@ -564,7 +535,10 @@ public void Init(BlockTemplate blockTemplate, string jobId, this.poolAddressDestination = poolAddressDestination; BlockTemplate = blockTemplate; JobId = jobId; - Difficulty = new Target(new NBitcoin.BouncyCastle.Math.BigInteger(BlockTemplate.Target, 16)).Difficulty; + + //Difficulty = new Target(new NBitcoin.BouncyCastle.Math.BigInteger(BlockTemplate.Target, 16)).Difficulty; + Difficulty = new Target(System.Numerics.BigInteger.Parse(BlockTemplate.Target, NumberStyles.HexNumber)).Difficulty; + extraNoncePlaceHolderLength = BitcoinConstants.ExtranoncePlaceHolderLength; this.isPoS = isPoS; this.shareMultiplier = shareMultiplier; @@ -623,7 +597,7 @@ public void Init(BlockTemplate blockTemplate, string jobId, public object GetJobParams(bool isNew) { - jobParams[jobParams.Length - 1] = isNew; + jobParams[^1] = isNew; return jobParams; } diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManager.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManager.cs index 49825f6904..f426db9d0c 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManager.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManager.cs @@ -36,6 +36,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Miningcore.Stratum; using Miningcore.Time; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using NLog; namespace Miningcore.Blockchain.Bitcoin @@ -53,12 +54,27 @@ public BitcoinJobManager( private BitcoinTemplate coin; + protected override object[] GetBlockTemplateParams() + { + var result = base.GetBlockTemplateParams(); + + if(coin.BlockTemplateRpcExtraParams != null) + { + if(coin.BlockTemplateRpcExtraParams.Type == JTokenType.Array) + result = result.Concat(coin.BlockTemplateRpcExtraParams.ToObject()).ToArray(); + else + result = result.Concat(new []{ coin.BlockTemplateRpcExtraParams.ToObject()}).ToArray(); + } + + return result; + } + protected async Task> GetBlockTemplateAsync() { logger.LogInvoke(); var result = await daemon.ExecuteCmdAnyAsync(logger, - BitcoinCommands.GetBlockTemplate, extraPoolConfig?.GBTArgs ?? (object) getBlockTemplateParams); + BitcoinCommands.GetBlockTemplate, extraPoolConfig?.GBTArgs ?? (object) GetBlockTemplateParams()); return result; } @@ -77,11 +93,7 @@ protected DaemonResponse GetBlockTemplateFromJson(string json) private BitcoinJob CreateJob() { - //switch (coin.Subfamily) - //{ - //} - - return new BitcoinJob(); + return new(); } protected override async Task<(bool IsNew, bool Force)> UpdateJob(bool forceUpdate, string via = null, string json = null) @@ -148,6 +160,14 @@ await GetBlockTemplateAsync() : BlockchainStats.NextNetworkBits = blockTemplate.Bits; } + else + { + if(via != null) + logger.Debug(() => $"Template update {blockTemplate.Height} [{via}]"); + else + logger.Debug(() => $"Template update {blockTemplate.Height}"); + } + currentJob = job; } diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManagerBase.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManagerBase.cs index b5d5ed4662..0808825cdc 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManagerBase.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinJobManagerBase.cs @@ -71,7 +71,7 @@ protected BitcoinJobManagerBase( protected bool hasLegacyDaemon; protected BitcoinPoolConfigExtra extraPoolConfig; protected BitcoinPoolPaymentProcessingConfigExtra extraPoolPaymentProcessingConfig; - protected readonly List validJobs = new List(); + protected readonly List validJobs = new(); protected DateTime? lastJobRebroadcast; protected bool hasSubmitBlockMethod; protected bool isPoS; @@ -79,13 +79,16 @@ protected BitcoinJobManagerBase( protected Network network; protected IDestination poolAddressDestination; - protected object[] getBlockTemplateParams = + protected virtual object[] GetBlockTemplateParams() { - new + return new object[] { - rules = new[] { "segwit" } - } - }; + new + { + rules = new[] {"segwit"}, + } + }; + } protected virtual void SetupJobUpdates() { @@ -434,7 +437,7 @@ protected override async Task EnsureDaemonsSynchedAsync(CancellationToken ct) while(true) { var responses = await daemon.ExecuteCmdAllAsync(logger, - BitcoinCommands.GetBlockTemplate, getBlockTemplateParams); + BitcoinCommands.GetBlockTemplate, GetBlockTemplateParams()); var isSynched = responses.All(x => x.Error == null); @@ -495,14 +498,22 @@ protected override async Task PostStartInitAsync(CancellationToken ct) PostChainIdentifyConfigure(); // ensure pool owns wallet - if(validateAddressResponse == null || !validateAddressResponse.IsValid) + if(validateAddressResponse is not {IsValid: true}) logger.ThrowLogPoolStartupException($"Daemon reports pool-address '{poolConfig.Address}' as invalid"); - isPoS = difficultyResponse.Values().Any(x => x.Path == "proof-of-stake"); + var coinTemplate = poolConfig.Template as BitcoinTemplate; + + isPoS = coinTemplate.IsPseudoPoS || difficultyResponse.Values().Any(x => x.Path == "proof-of-stake"); // Create pool address script from response if(!isPoS) + { + if(extraPoolConfig?.AddressType != BitcoinAddressType.Legacy) + logger.Info(()=> $"Interpreting pool address {poolConfig.Address} as type {extraPoolConfig?.AddressType.ToString()}"); + poolAddressDestination = AddressToDestination(poolConfig.Address, extraPoolConfig?.AddressType); + } + else poolAddressDestination = new PubKey(poolConfig.PubKey ?? validateAddressResponse.PubKey); @@ -564,6 +575,9 @@ protected virtual IDestination AddressToDestination(string address, BitcoinAddre case BitcoinAddressType.BechSegwit: return BitcoinUtils.BechSegwitAddressToDestination(poolConfig.Address, network); + case BitcoinAddressType.BCash: + return BitcoinUtils.BCashAddressToDestination(poolConfig.Address, network); + default: return BitcoinUtils.AddressToDestination(poolConfig.Address, network); } @@ -599,7 +613,7 @@ protected void ConfigureRewards() public Network Network => network; public IObservable Jobs { get; private set; } - public BlockchainStats BlockchainStats { get; } = new BlockchainStats(); + public BlockchainStats BlockchainStats { get; } = new(); public override void Configure(PoolConfig poolConfig, ClusterConfig clusterConfig) { @@ -621,7 +635,7 @@ public virtual async Task ValidateAddressAsync(string address, Cancellatio var result = await daemon.ExecuteCmdAnyAsync(logger, ct, BitcoinCommands.ValidateAddress, new[] { address }); - return result.Response != null && result.Response.IsValid; + return result.Response is {IsValid: true}; } public abstract object[] GetSubscriberData(StratumClient worker); diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinPayoutHandler.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinPayoutHandler.cs index af61c8806a..1c4aa28e6e 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinPayoutHandler.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinPayoutHandler.cs @@ -139,6 +139,8 @@ public virtual async Task ClassifyBlocksAsync(Block[] blocks) block.Status = BlockStatus.Orphaned; block.Reward = 0; result.Add(block); + + logger.Info(() => $"[{LogCategory}] Block {block.BlockHeight} classified as orphaned due to daemon error {cmdResult.Error.Code}"); } else @@ -153,6 +155,8 @@ public virtual async Task ClassifyBlocksAsync(Block[] blocks) block.Status = BlockStatus.Orphaned; block.Reward = 0; result.Add(block); + + logger.Info(() => $"[{LogCategory}] Block {block.BlockHeight} classified as orphaned due to missing tx details"); } else @@ -234,7 +238,14 @@ public virtual async Task PayoutAsync(Balance[] balances) amounts, // addresses and associated amounts 1, // only spend funds covered by this many confirmations comment, // tx comment - subtractFeesFrom // distribute transaction fee equally over all recipients + subtractFeesFrom, // distribute transaction fee equally over all recipients, + + // workaround for https://bitcoin.stackexchange.com/questions/102508/bitcoin-cli-sendtoaddress-error-fallbackfee-is-disabled-wait-a-few-blocks-or-en + // using bitcoin regtest + //true, + //null, + //"unset", + //"1" }; } diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinPool.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinPool.cs index f5636ea610..289bdded27 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinPool.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinPool.cs @@ -128,6 +128,7 @@ protected virtual async Task OnAuthorizeAsync(StratumClient client, Timestamped< // extract control vars from password var staticDiff = GetStaticDiffFromPassparts(passParts); + if(staticDiff.HasValue && (context.VarDiff != null && staticDiff.Value >= context.VarDiff.Config.MinDiff || context.VarDiff == null && staticDiff.Value > context.Difficulty)) diff --git a/src/Miningcore/Blockchain/Bitcoin/BitcoinUtils.cs b/src/Miningcore/Blockchain/Bitcoin/BitcoinUtils.cs index 1119f26250..799595bbac 100644 --- a/src/Miningcore/Blockchain/Bitcoin/BitcoinUtils.cs +++ b/src/Miningcore/Blockchain/Bitcoin/BitcoinUtils.cs @@ -56,5 +56,12 @@ public static IDestination BechSegwitAddressToDestination(string address, Networ Debug.Assert(result.GetAddress(expectedNetwork).ToString() == address); return result; } + + public static IDestination BCashAddressToDestination(string address, Network expectedNetwork) + { + var bcash = NBitcoin.Altcoins.BCash.Instance.GetNetwork(expectedNetwork.ChainName); + var trashAddress = bcash.Parse(address); + return trashAddress.ScriptPubKey.GetDestinationAddress(bcash); + } } } diff --git a/src/Miningcore/Blockchain/Bitcoin/DaemonResponses/GetNetworkInfoResponse.cs b/src/Miningcore/Blockchain/Bitcoin/DaemonResponses/GetNetworkInfoResponse.cs index b2f36ea87d..8d3daeaf7c 100644 --- a/src/Miningcore/Blockchain/Bitcoin/DaemonResponses/GetNetworkInfoResponse.cs +++ b/src/Miningcore/Blockchain/Bitcoin/DaemonResponses/GetNetworkInfoResponse.cs @@ -1,20 +1,20 @@ -/* +/* Copyright 2017 Coin Foundry (coinfoundry.org) Authors: Oliver Weichhold (oliver@weichhold.com) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ diff --git a/src/Miningcore/Blockchain/CoinMetaData.cs b/src/Miningcore/Blockchain/CoinMetaData.cs index ffd72cc5a1..2154534082 100644 --- a/src/Miningcore/Blockchain/CoinMetaData.cs +++ b/src/Miningcore/Blockchain/CoinMetaData.cs @@ -6,7 +6,7 @@ public static class DevDonation { public const decimal Percent = 0.1m; - public static readonly Dictionary Addresses = new Dictionary + public static readonly Dictionary Addresses = new() { { "BTC", "17QnVor1B6oK1rWnVVBrdX9gFzVkZZbhDm" }, { "BCH", "qrf6uhhapq7fgkjv2ce2hcjqpk8ec2zc25et4xsphv" }, diff --git a/src/Miningcore/Blockchain/Cryptonote/Configuration/CryptonotePoolConfigExtra.cs b/src/Miningcore/Blockchain/Cryptonote/Configuration/CryptonotePoolConfigExtra.cs index c535ac30d0..c47c798801 100644 --- a/src/Miningcore/Blockchain/Cryptonote/Configuration/CryptonotePoolConfigExtra.cs +++ b/src/Miningcore/Blockchain/Cryptonote/Configuration/CryptonotePoolConfigExtra.cs @@ -19,6 +19,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using Miningcore.Configuration; +using Miningcore.Native; +using Newtonsoft.Json.Linq; namespace Miningcore.Blockchain.Cryptonote.Configuration { @@ -28,5 +30,16 @@ public class CryptonotePoolConfigExtra /// Blocktemplate stream published via ZMQ /// public ZmqPubSubEndpointConfig BtStream { get; set; } + + /// + /// Optional override value for RandomX VM Flags (see Native/LibRandomX.cs) + /// + public JToken RandomXFlagsOverride { get; set; } + + /// + /// Optional value for number of RandomX VMs allocated per generation (new seed hash) + /// Set to -1 to scale to number of cores + /// + public int RandomXVMCount { get; set; } = 1; } } diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonoteConstants.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonoteConstants.cs index c65415459b..751c6c8250 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonoteConstants.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonoteConstants.cs @@ -31,7 +31,8 @@ namespace Miningcore.Blockchain.Cryptonote public enum CryptonoteNetworkType { Main = 1, - Test + Test, + Stage } public class CryptonoteConstants @@ -44,9 +45,9 @@ public class CryptonoteConstants public const char MainNetAddressPrefix = '4'; public const char TestNetAddressPrefix = '9'; public const int PaymentIdHexLength = 64; - public static readonly Regex RegexValidNonce = new Regex("^[0-9a-f]{8}$", RegexOptions.Compiled); + public static readonly Regex RegexValidNonce = new("^[0-9a-f]{8}$", RegexOptions.Compiled); - public static readonly BigInteger Diff1 = new BigInteger("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16); + public static readonly BigInteger Diff1 = new("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 16); public static readonly System.Numerics.BigInteger Diff1b = System.Numerics.BigInteger.Parse("00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", NumberStyles.HexNumber); #if DEBUG diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonoteJob.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonoteJob.cs index 74ad72f0c3..155522df98 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonoteJob.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonoteJob.cs @@ -28,7 +28,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Miningcore.Stratum; using Miningcore.Util; using NBitcoin.BouncyCastle.Math; -using static Miningcore.Native.LibCryptonight; using Contract = Miningcore.Contracts.Contract; namespace Miningcore.Blockchain.Cryptonote @@ -36,7 +35,8 @@ namespace Miningcore.Blockchain.Cryptonote public class CryptonoteJob { public CryptonoteJob(GetBlockTemplateResponse blockTemplate, byte[] instanceId, string jobId, - PoolConfig poolConfig, ClusterConfig clusterConfig, string prevHash) + PoolConfig poolConfig, ClusterConfig clusterConfig, string prevHash, + LibRandomX.randomx_flags? randomXFlagsOverride, int randomXvmCount) { Contract.RequiresNonNull(blockTemplate, nameof(blockTemplate)); Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); @@ -49,26 +49,27 @@ public CryptonoteJob(GetBlockTemplateResponse blockTemplate, byte[] instanceId, PrepareBlobTemplate(instanceId); PrevHash = prevHash; + if(!string.IsNullOrEmpty(blockTemplate.SeedHash)) + seedHashBytes = blockTemplate.SeedHash.HexToByteArray(); + switch(coin.Hash) { - case CryptonightHashType.Normal: - hashFunc = LibCryptonight.Cryptonight; - break; - - case CryptonightHashType.Lite: - hashFunc = LibCryptonight.CryptonightLight; - break; - - case CryptonightHashType.Heavy: - hashFunc = LibCryptonight.CryptonightHeavy; + case CryptonightHashType.RandomX: + hashFunc = ((key, data, result, height) => + { + LibRandomX.CalculateHash(key, data, result, randomXFlagsOverride, randomXvmCount); + }); break; } } + public delegate void HashFunc(byte[] key, ReadOnlySpan data, Span result, ulong height); + private byte[] blobTemplate; + private readonly byte[] seedHashBytes; private int extraNonce; private readonly CryptonoteCoinTemplate coin; - private readonly LibCryptonight.CryptonightHash hashFunc; + private readonly HashFunc hashFunc; private void PrepareBlobTemplate(byte[] instanceId) { @@ -91,7 +92,7 @@ private string EncodeBlob(uint workerExtraNonce) return LibCryptonote.ConvertBlob(blob, blobTemplate.Length).ToHexString(); } - private string EncodeTarget(double difficulty) + private string EncodeTarget(double difficulty, int size = 4) { var diff = BigInteger.ValueOf((long) (difficulty * 255d)); var quotient = CryptonoteConstants.Diff1.Divide(diff).Multiply(BigInteger.ValueOf(255)); @@ -103,7 +104,7 @@ private string EncodeTarget(double difficulty) if(padLength > 0) bytes.CopyTo(padded.Slice(padLength, bytes.Length)); - padded = padded.Slice(0, 4); + padded = padded[..size]; padded.Reverse(); return padded.ToHexString(); @@ -114,7 +115,7 @@ private void ComputeBlockHash(ReadOnlySpan blobConverted, Span resul // blockhash is computed from the converted blob data prefixed with its length Span block = stackalloc byte[blobConverted.Length + 1]; block[0] = (byte) blobConverted.Length; - blobConverted.CopyTo(block.Slice(1)); + blobConverted.CopyTo(block[1..]); LibCryptonote.CryptonightHashFast(block, result); } @@ -128,6 +129,7 @@ public void PrepareWorkerJob(CryptonoteWorkerJob workerJob, out string blob, out { workerJob.Height = BlockTemplate.Height; workerJob.ExtraNonce = (uint) Interlocked.Increment(ref extraNonce); + workerJob.SeedHash = BlockTemplate.SeedHash; if(extraNonce < 0) extraNonce = 0; @@ -165,35 +167,9 @@ public void PrepareWorkerJob(CryptonoteWorkerJob workerJob, out string blob, out if(blobConverted == null) throw new StratumException(StratumError.MinusOne, "malformed blob"); - // determine variant - CryptonightVariant variant = CryptonightVariant.VARIANT_0; - - if(coin.HashVariant != 0) - variant = (CryptonightVariant) coin.HashVariant; - else - { - switch(coin.Hash) - { - case CryptonightHashType.Normal: - variant = (blobConverted[0] >= 10) ? CryptonightVariant.VARIANT_4 : - ((blobConverted[0] >= 8) ? CryptonightVariant.VARIANT_2 : - ((blobConverted[0] == 7) ? CryptonightVariant.VARIANT_1 : - CryptonightVariant.VARIANT_0)); - break; - - case CryptonightHashType.Lite: - variant = CryptonightVariant.VARIANT_1; - break; - - case CryptonightHashType.Heavy: - variant = CryptonightVariant.VARIANT_0; - break; - } - } - // hash it Span headerHash = stackalloc byte[32]; - hashFunc(blobConverted, headerHash, variant, BlockTemplate.Height); + hashFunc(seedHashBytes, blobConverted, headerHash, BlockTemplate.Height); var headerHashString = headerHash.ToHexString(); if(headerHashString != workerHash) diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonoteJobManager.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonoteJobManager.cs index 90f26dedb0..3b7ae43eec 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonoteJobManager.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonoteJobManager.cs @@ -46,6 +46,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Miningcore.Util; using MoreLinq; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using NLog; using Contract = Miningcore.Contracts.Contract; @@ -79,7 +80,8 @@ public CryptonoteJobManager( private readonly IMasterClock clock; private CryptonoteNetworkType networkType; private CryptonotePoolConfigExtra extraPoolConfig; - private UInt64 poolAddressBase58Prefix; + private LibRandomX.randomx_flags? randomXFlagsOverride; + private ulong poolAddressBase58Prefix; private DaemonEndpointConfig[] walletDaemonEndpoints; protected async Task UpdateJob(string via = null, string json = null) @@ -112,7 +114,7 @@ protected async Task UpdateJob(string via = null, string json = null) else logger.Info(() => $"Detected new block {blockTemplate.Height}"); - job = new CryptonoteJob(blockTemplate, instanceId, NextJobId(), poolConfig, clusterConfig, newHash); + job = new CryptonoteJob(blockTemplate, instanceId, NextJobId(), poolConfig, clusterConfig, newHash, randomXFlagsOverride, extraPoolConfig.RandomXVMCount); currentJob = job; // update stats @@ -123,6 +125,14 @@ protected async Task UpdateJob(string via = null, string json = null) BlockchainStats.NextNetworkBits = ""; } + else + { + if(via != null) + logger.Debug(() => $"Template update {blockTemplate.Height} [{via}]"); + else + logger.Debug(() => $"Template update {blockTemplate.Height}"); + } + return isNew; } @@ -210,7 +220,7 @@ private async Task SubmitBlockAsync(Share share, string blobHex, string bl { var error = response.Error?.Message ?? response.Response?.Status; - logger.Warn(() => $"Block {share.BlockHeight} [{blobHash.Substring(0, 6)}] submission failed with: {error}"); + logger.Warn(() => $"Block {share.BlockHeight} [{blobHash[..6]}] submission failed with: {error}"); messageBus.SendMessage(new AdminNotification("Block submission failed", $"Pool {poolConfig.Id} {(!string.IsNullOrEmpty(share.Source) ? $"[{share.Source.ToUpper()}] " : string.Empty)}failed to submit block {share.BlockHeight}: {error}")); return false; } @@ -232,6 +242,8 @@ public override void Configure(PoolConfig poolConfig, ClusterConfig clusterConfi this.clusterConfig = clusterConfig; extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs(); + randomXFlagsOverride = MakeRandomXFlags(extraPoolConfig.RandomXFlagsOverride); + // extract standard daemon endpoints daemonEndpoints = poolConfig.Daemons .Where(x => string.IsNullOrEmpty(x.Category)) @@ -254,9 +266,6 @@ public override void Configure(PoolConfig poolConfig, ClusterConfig clusterConfi if(string.IsNullOrEmpty(x.HttpPath)) x.HttpPath = CryptonoteConstants.DaemonRpcLocation; - // cryptonote daemons only support digest auth - x.DigestAuth = true; - return x; }) .ToArray(); @@ -294,7 +303,7 @@ public bool ValidateAddress(string address) return true; } - public BlockchainStats BlockchainStats { get; } = new BlockchainStats(); + public BlockchainStats BlockchainStats { get; } = new(); public void PrepareWorkerJob(CryptonoteWorkerJob workerJob, out string blob, out string target) { @@ -341,13 +350,13 @@ public async ValueTask SubmitShareAsync(StratumClient worker, // if block candidate, submit & check if accepted by network if(share.IsBlockCandidate) { - logger.Info(() => $"Submitting block {share.BlockHeight} [{share.BlockHash.Substring(0, 6)}]"); + logger.Info(() => $"Submitting block {share.BlockHeight} [{share.BlockHash[..6]}]"); share.IsBlockCandidate = await SubmitBlockAsync(share, blobHex, share.BlockHash); if(share.IsBlockCandidate) { - logger.Info(() => $"Daemon accepted block {share.BlockHeight} [{share.BlockHash.Substring(0, 6)}] submitted by {context.Miner}"); + logger.Info(() => $"Daemon accepted block {share.BlockHeight} [{share.BlockHash[..6]}] submitted by {context.Miner}"); OnBlockFound(); @@ -366,6 +375,30 @@ public async ValueTask SubmitShareAsync(StratumClient worker, #endregion // API-Surface + private LibRandomX.randomx_flags? MakeRandomXFlags(JToken token) + { + if(token == null) + return null; + + if(token.Type == JTokenType.Integer) + return (LibRandomX.randomx_flags) token.Value(); + else if(token.Type == JTokenType.String) + { + LibRandomX.randomx_flags result = 0; + var value = token.Value(); + + foreach(var flag in value.Split("|").Select(x=> x.Trim()).Where(x=> !string.IsNullOrEmpty(x))) + { + if(Enum.TryParse(typeof(LibRandomX.randomx_flags), flag, true, out var flagVal)) + result |= (LibRandomX.randomx_flags) flagVal; + } + + return result; + } + + return null; + } + #region Overrides protected override void ConfigureDaemons() @@ -393,7 +426,7 @@ protected override async Task AreDaemonsHealthyAsync() .Any(x => x.Code == HttpStatusCode.Unauthorized)) logger.ThrowLogPoolStartupException($"Daemon reports invalid credentials"); - if(!responses.All(x => x.Error == null)) + if(responses.Any(x => x.Error != null)) return false; if(clusterConfig.PaymentProcessing?.Enabled == true && poolConfig.PaymentProcessing?.Enabled == true) @@ -476,7 +509,27 @@ protected override async Task PostStartInitAsync(CancellationToken ct) var info = infoResponse.Response.ToObject(); // chain detection - networkType = info.IsTestnet ? CryptonoteNetworkType.Test : CryptonoteNetworkType.Main; + if(!string.IsNullOrEmpty(info.NetType)) + { + switch(info.NetType.ToLower()) + { + case "mainnet": + networkType = CryptonoteNetworkType.Main; + break; + case "stagenet": + networkType = CryptonoteNetworkType.Stage; + break; + case "testnet": + networkType = CryptonoteNetworkType.Test; + break; + default: + logger.ThrowLogPoolStartupException($"Unsupport net type '{info.NetType}'"); + break; + } + } + + else + networkType = info.IsTestnet ? CryptonoteNetworkType.Test : CryptonoteNetworkType.Main; // address validation poolAddressBase58Prefix = LibCryptonote.DecodeAddress(poolConfig.Address); @@ -490,9 +543,14 @@ protected override async Task PostStartInitAsync(CancellationToken ct) logger.ThrowLogPoolStartupException($"Invalid pool address prefix. Expected {coin.AddressPrefix}, got {poolAddressBase58Prefix}"); break; + case CryptonoteNetworkType.Stage: + if(poolAddressBase58Prefix != coin.AddressPrefixStagenet) + logger.ThrowLogPoolStartupException($"Invalid pool address prefix. Expected {coin.AddressPrefixStagenet}, got {poolAddressBase58Prefix}"); + break; + case CryptonoteNetworkType.Test: if(poolAddressBase58Prefix != coin.AddressPrefixTestnet) - logger.ThrowLogPoolStartupException($"Invalid pool address prefix. Expected {coin.AddressPrefix}, got {poolAddressBase58Prefix}"); + logger.ThrowLogPoolStartupException($"Invalid pool address prefix. Expected {coin.AddressPrefixTestnet}, got {poolAddressBase58Prefix}"); break; } diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonotePayoutHandler.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonotePayoutHandler.cs index 1b772cb4e0..c26d377c37 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonotePayoutHandler.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonotePayoutHandler.cs @@ -42,8 +42,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using Newtonsoft.Json; using Contract = Miningcore.Contracts.Contract; using CNC = Miningcore.Blockchain.Cryptonote.CryptonoteCommands; -using Miningcore.Notifications.Messages; -using System.Globalization; using Newtonsoft.Json.Linq; namespace Miningcore.Blockchain.Cryptonote @@ -130,17 +128,36 @@ private async Task HandleTransferResponseAsync(DaemonResponse GetNetworkTypeAsync() + private async Task UpdateNetworkTypeAsync() { if(!networkType.HasValue) { - var infoResponse = await daemon.ExecuteCmdAnyAsync(logger, CryptonoteCommands.GetInfo, true); + var infoResponse = await daemon.ExecuteCmdAnyAsync(logger, CNC.GetInfo, true); var info = infoResponse.Response.ToObject(); - networkType = info.IsTestnet ? CryptonoteNetworkType.Test : CryptonoteNetworkType.Main; - } + // chain detection + if(!string.IsNullOrEmpty(info.NetType)) + { + switch(info.NetType.ToLower()) + { + case "mainnet": + networkType = CryptonoteNetworkType.Main; + break; + case "stagenet": + networkType = CryptonoteNetworkType.Stage; + break; + case "testnet": + networkType = CryptonoteNetworkType.Test; + break; + default: + logger.ThrowLogPoolStartupException($"Unsupport net type '{info.NetType}'"); + break; + } + } - return networkType.Value; + else + networkType = info.IsTestnet ? CryptonoteNetworkType.Test : CryptonoteNetworkType.Main; + } } private async Task EnsureBalance(decimal requiredAmount, CryptonoteCoinTemplate coin) @@ -156,13 +173,13 @@ private async Task EnsureBalance(decimal requiredAmount, CryptonoteCoinTem var unlockedBalance = Math.Floor(response.Response.UnlockedBalance / coin.SmallestUnit); var balance = Math.Floor(response.Response.Balance / coin.SmallestUnit); - if(response.Response.UnlockedBalance < requiredAmount) + if(unlockedBalance < requiredAmount) { - logger.Error(() => $"[{LogCategory}] Need {FormatAmount(requiredAmount)} unlocked balance, but only have {FormatAmount(unlockedBalance)} ({FormatAmount(balance)})"); + logger.Info(() => $"[{LogCategory}] {FormatAmount(requiredAmount)} unlocked balance required for payout, but only have {FormatAmount(unlockedBalance)} of {FormatAmount(balance)} available yet. Will try again."); return false; } - logger.Error(() => $"[{LogCategory}] Current balance is {FormatAmount(unlockedBalance)}"); + logger.Info(() => $"[{LogCategory}] Current balance is {FormatAmount(unlockedBalance)}"); return true; } @@ -225,11 +242,11 @@ private void ExtractAddressAndPaymentId(string input, out string address, out st if(index != -1) { - address = input.Substring(0, index); + address = input[..index]; if(index + 1 < input.Length) { - paymentId = input.Substring(index + 1); + paymentId = input[(index + 1)..]; // ignore invalid payment ids if(paymentId.Length != CryptonoteConstants.PaymentIdHexLength) @@ -337,7 +354,9 @@ public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolCon walletDaemon.Configure(walletDaemonEndpoints); // detect network - await GetNetworkTypeAsync(); + await UpdateNetworkTypeAsync(); + +var response1 = await walletDaemon.ExecuteCmdSingleAsync(logger, CryptonoteWalletCommands.GetBalance); // detect transfer_split support var response = await walletDaemon.ExecuteCmdSingleAsync(logger, CryptonoteWalletCommands.TransferSplit); @@ -368,7 +387,7 @@ public async Task ClassifyBlocksAsync(Block[] blocks) var block = page[j]; var rpcResult = await daemon.ExecuteCmdAnyAsync(logger, - CryptonoteCommands.GetBlockHeaderByHeight, + CNC.GetBlockHeaderByHeight, new GetBlockHeaderByHeightRequest { Height = block.BlockHeight @@ -474,6 +493,16 @@ public async Task PayoutAsync(Balance[] balances) break; + case CryptonoteNetworkType.Stage: + if(addressPrefix != coin.AddressPrefixStagenet && + addressIntegratedPrefix != coin.AddressPrefixIntegratedStagenet) + { + logger.Warn(() => $"[{LogCategory}] Excluding payment to invalid address {x.Address}"); + return false; + } + + break; + case CryptonoteNetworkType.Test: if(addressPrefix != coin.AddressPrefixTestnet && addressIntegratedPrefix != coin.AddressPrefixIntegratedTestnet) diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonotePool.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonotePool.cs index 291c468f76..73677b50db 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonotePool.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonotePool.cs @@ -86,14 +86,14 @@ private async Task OnLoginAsync(StratumClient client, Timestamped public string Worker { get; set; } - private List validJobs { get; } = new List(); + private List validJobs { get; } = new(); public void AddJob(CryptonoteWorkerJob job) { diff --git a/src/Miningcore/Blockchain/Cryptonote/CryptonoteWorkerJob.cs b/src/Miningcore/Blockchain/Cryptonote/CryptonoteWorkerJob.cs index 85d2d24d13..b0d2406440 100644 --- a/src/Miningcore/Blockchain/Cryptonote/CryptonoteWorkerJob.cs +++ b/src/Miningcore/Blockchain/Cryptonote/CryptonoteWorkerJob.cs @@ -19,6 +19,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; +using System.Collections.Concurrent; using System.Collections.Generic; namespace Miningcore.Blockchain.Cryptonote @@ -35,7 +36,8 @@ public CryptonoteWorkerJob(string jobId, double difficulty) public uint Height { get; set; } public uint ExtraNonce { get; set; } public double Difficulty { get; set; } + public string SeedHash { get; set; } - public HashSet Submissions { get; } = new HashSet(StringComparer.OrdinalIgnoreCase); + public readonly ConcurrentDictionary Submissions = new(StringComparer.OrdinalIgnoreCase); } } diff --git a/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetBlockTemplateResponse.cs b/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetBlockTemplateResponse.cs index 514489eee6..bc2befa773 100644 --- a/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetBlockTemplateResponse.cs +++ b/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetBlockTemplateResponse.cs @@ -33,6 +33,9 @@ public class GetBlockTemplateResponse [JsonProperty("prev_hash")] public string PreviousBlockhash { get; set; } + [JsonProperty("seed_hash")] + public string SeedHash { get; set; } + [JsonProperty("reserved_offset")] public int ReservedOffset { get; set; } diff --git a/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetInfoResponse.cs b/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetInfoResponse.cs index e36872ba68..94d651a1b8 100644 --- a/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetInfoResponse.cs +++ b/src/Miningcore/Blockchain/Cryptonote/DaemonResponses/GetInfoResponse.cs @@ -41,6 +41,12 @@ public class GetInfoResponse [JsonProperty("testnet")] public bool IsTestnet { get; set; } + /// + /// States if the node is on the testnet(true) or mainnet(false). + /// + [JsonProperty("nettype")] + public string NetType { get; set; } + /// /// Hash of the highest block in the chain. /// diff --git a/src/Miningcore/Blockchain/Cryptonote/StratumResponses/CryptonoteLoginResponse.cs b/src/Miningcore/Blockchain/Cryptonote/StratumResponses/CryptonoteLoginResponse.cs index 3234ef078d..852ccc5623 100644 --- a/src/Miningcore/Blockchain/Cryptonote/StratumResponses/CryptonoteLoginResponse.cs +++ b/src/Miningcore/Blockchain/Cryptonote/StratumResponses/CryptonoteLoginResponse.cs @@ -30,6 +30,9 @@ public class CryptonoteJobParams public string Blob { get; set; } public string Target { get; set; } + [JsonProperty("seed_hash")] + public string SeedHash { get; set; } + /// /// Introduced for CNv4 (aka CryptonightR) /// diff --git a/src/Miningcore/Blockchain/Equihash/Custom/BitcoinGold/BitcoinGoldJob.cs b/src/Miningcore/Blockchain/Equihash/Custom/BitcoinGold/BitcoinGoldJob.cs index 0de021e406..6431f59e8f 100644 --- a/src/Miningcore/Blockchain/Equihash/Custom/BitcoinGold/BitcoinGoldJob.cs +++ b/src/Miningcore/Blockchain/Equihash/Custom/BitcoinGold/BitcoinGoldJob.cs @@ -52,6 +52,8 @@ protected override Transaction CreateOutputTransaction() // pool reward (t-addr) tx.Outputs.Add(rewardToPool, poolAddressDestination); + tx.Inputs.Add(TxIn.CreateCoinbase((int) BlockTemplate.Height)); + return tx; } @@ -198,7 +200,7 @@ public override void Init(EquihashBlockTemplate blockTemplate, string jobId, BuildCoinbase(); // build tx hashes - var txHashes = new List { new uint256(coinbaseInitialHash) }; + var txHashes = new List { new(coinbaseInitialHash) }; txHashes.AddRange(BlockTemplate.Transactions.Select(tx => new uint256(tx.TxId.HexToReverseByteArray()))); // build merkle root diff --git a/src/Miningcore/Blockchain/Equihash/Custom/Minexcoin/MinexcoinJob.cs b/src/Miningcore/Blockchain/Equihash/Custom/Minexcoin/MinexcoinJob.cs index c423d95590..76e08d41dc 100644 --- a/src/Miningcore/Blockchain/Equihash/Custom/Minexcoin/MinexcoinJob.cs +++ b/src/Miningcore/Blockchain/Equihash/Custom/Minexcoin/MinexcoinJob.cs @@ -28,7 +28,7 @@ namespace Miningcore.Blockchain.Equihash.Custom.Minexcoin { public class MinexcoinJob : EquihashJob { - private static readonly Script bankScript = new Script("2103ae6efe9458f1d3bdd9a458b1970eabbdf9fcb1357e0dff2744a777ff43c391eeac".HexToByteArray()); + private static readonly Script bankScript = new("2103ae6efe9458f1d3bdd9a458b1970eabbdf9fcb1357e0dff2744a777ff43c391eeac".HexToByteArray()); private const decimal BlockReward = 250000000m; // Minexcoin has a static block reward protected override Transaction CreateOutputTransaction() @@ -47,6 +47,8 @@ protected override Transaction CreateOutputTransaction() // bank reward tx.Outputs.Add(bankReward, bankScript); + tx.Inputs.Add(TxIn.CreateCoinbase((int) BlockTemplate.Height)); + return tx; } diff --git a/src/Miningcore/Blockchain/Equihash/EquihashBlockHeader.cs b/src/Miningcore/Blockchain/Equihash/EquihashBlockHeader.cs index c3dbabf085..461a4b55ff 100644 --- a/src/Miningcore/Blockchain/Equihash/EquihashBlockHeader.cs +++ b/src/Miningcore/Blockchain/Equihash/EquihashBlockHeader.cs @@ -102,7 +102,7 @@ public void ReadWrite(BitcoinStream stream) public static EquihashBlockHeader Parse(string hex) { - return new EquihashBlockHeader(Encoders.Hex.DecodeData(hex)); + return new(Encoders.Hex.DecodeData(hex)); } internal void SetNull() diff --git a/src/Miningcore/Blockchain/Equihash/EquihashJob.cs b/src/Miningcore/Blockchain/Equihash/EquihashJob.cs index 411eebecdd..f858b45dce 100644 --- a/src/Miningcore/Blockchain/Equihash/EquihashJob.cs +++ b/src/Miningcore/Blockchain/Equihash/EquihashJob.cs @@ -19,6 +19,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -50,7 +51,7 @@ public class EquihashJob protected Network network; protected IDestination poolAddressDestination; - protected readonly HashSet submissions = new HashSet(StringComparer.OrdinalIgnoreCase); + protected readonly ConcurrentDictionary submissions = new(StringComparer.OrdinalIgnoreCase); protected uint256 blockTargetValue; protected byte[] coinbaseInitial; @@ -140,6 +141,8 @@ protected virtual Transaction CreateOutputTransaction() tx.Outputs.Add(rewardToPool, poolAddressDestination); } + tx.Inputs.Add(TxIn.CreateCoinbase((int) BlockTemplate.Height)); + return tx; } @@ -156,7 +159,6 @@ protected virtual void BuildCoinbase() { // output transaction txOut = CreateOutputTransaction(); - txOut.Inputs.Add(TxIn.CreateCoinbase((int) BlockTemplate.Height)); using(var stream = new MemoryStream()) { @@ -233,13 +235,13 @@ private byte[] SerializeBlock(Span header, Span coinbase, Span var headerBytes = SerializeHeader(nTime, nonce); // verify solution - if(!solver.Verify(headerBytes, solutionBytes.Slice(networkParams.SolutionPreambleSize))) + if(!solver.Verify(headerBytes, solutionBytes[networkParams.SolutionPreambleSize..])) throw new StratumException(StratumError.Other, "invalid solution"); // concat header and solution Span headerSolutionBytes = stackalloc byte[headerBytes.Length + solutionBytes.Length]; headerBytes.CopyTo(headerSolutionBytes); - solutionBytes.CopyTo(headerSolutionBytes.Slice(headerBytes.Length)); + solutionBytes.CopyTo(headerSolutionBytes[headerBytes.Length..]); // hash block-header Span headerHash = stackalloc byte[32]; @@ -299,15 +301,9 @@ private byte[] SerializeBlock(Span header, Span coinbase, Span private bool RegisterSubmit(string nonce, string solution) { - lock(submissions) - { - var key = nonce.ToLower() + solution.ToLower(); - if(submissions.Contains(key)) - return false; + var key = nonce + solution; - submissions.Add(key); - return true; - } + return submissions.TryAdd(key, true); } #region API-Surface @@ -396,7 +392,7 @@ public virtual void Init(EquihashBlockTemplate blockTemplate, string jobId, BuildCoinbase(); // build tx hashes - var txHashes = new List { new uint256(coinbaseInitialHash) }; + var txHashes = new List { new(coinbaseInitialHash) }; txHashes.AddRange(BlockTemplate.Transactions.Select(tx => new uint256(tx.Hash.HexToReverseByteArray()))); // build merkle root @@ -463,7 +459,7 @@ public virtual void Init(EquihashBlockTemplate blockTemplate, string jobId, public object GetJobParams(bool isNew) { - jobParams[jobParams.Length - 1] = isNew; + jobParams[^1] = isNew; return jobParams; } diff --git a/src/Miningcore/Blockchain/Equihash/EquihashJobManager.cs b/src/Miningcore/Blockchain/Equihash/EquihashJobManager.cs index 6c63218a77..f5042a5be9 100644 --- a/src/Miningcore/Blockchain/Equihash/EquihashJobManager.cs +++ b/src/Miningcore/Blockchain/Equihash/EquihashJobManager.cs @@ -33,7 +33,6 @@ public EquihashJobManager( IMessageBus messageBus, IExtraNonceProvider extraNonceProvider) : base(ctx, clock, messageBus, extraNonceProvider) { - getBlockTemplateParams = null; } private EquihashCoinTemplate coin; @@ -55,7 +54,7 @@ private async Task> GetBlockTemplateAsync( var subsidyResponse = await daemon.ExecuteCmdAnyAsync(logger, BitcoinCommands.GetBlockSubsidy); var result = await daemon.ExecuteCmdAnyAsync(logger, - BitcoinCommands.GetBlockTemplate, extraPoolConfig?.GBTArgs ?? (object) getBlockTemplateParams); + BitcoinCommands.GetBlockTemplate, extraPoolConfig?.GBTArgs ?? (object) GetBlockTemplateParams()); if(subsidyResponse.Error == null && result.Error == null && result.Response != null) result.Response.Subsidy = subsidyResponse.Response; @@ -164,6 +163,14 @@ await GetBlockTemplateAsync() : BlockchainStats.NextNetworkBits = blockTemplate.Bits; } + else + { + if(via != null) + logger.Debug(() => $"Template update {blockTemplate.Height} [{via}]"); + else + logger.Debug(() => $"Template update {blockTemplate.Height}"); + } + currentJob = job; } diff --git a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumDaemonEndpointConfigExtra.cs b/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumDaemonEndpointConfigExtra.cs deleted file mode 100644 index df01b52249..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumDaemonEndpointConfigExtra.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Miningcore.Blockchain.Ethereum.Configuration -{ - public class EthereumDaemonEndpointConfigExtra - { - /// - /// Optional port for streaming WebSocket data - /// - public int? PortWs { get; set; } - - /// - /// Optional http-path for streaming WebSocket data - /// - public string HttpPathWs { get; set; } - - /// - /// Optional: Use SSL to for daemon websocket streaming - /// - public bool SslWs { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolConfigExtra.cs b/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolConfigExtra.cs deleted file mode 100644 index 5d75d3557a..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolConfigExtra.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using Miningcore.Configuration; - -namespace Miningcore.Blockchain.Ethereum.Configuration -{ - public class EthereumPoolConfigExtra - { - /// - /// Base directory for generated DAGs - /// - public string DagDir { get; set; } - - /// - /// If true connects to Websocket port of all daemons and subscribes to streaming job updates for reduced latency - /// - public bool? EnableDaemonWebsocketStreaming { get; set; } - - /// - /// Useful to specify the real chain type when running geth - /// - public string ChainTypeOverride { get; set; } - - /// - /// getWork stream published via ZMQ - /// - public ZmqPubSubEndpointConfig BtStream { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonRequests/SendTransactionRequest.cs b/src/Miningcore/Blockchain/Ethereum/DaemonRequests/SendTransactionRequest.cs deleted file mode 100644 index d1e75ebe11..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/DaemonRequests/SendTransactionRequest.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System.Numerics; -using Miningcore.Serialization; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum.DaemonRequests -{ - public class SendTransactionRequest - { - /// - /// The address the transaction is send from. - /// - public string From { get; set; } - - /// - /// The address the transaction is directed to. - /// - public string To { get; set; } - - /// - /// (Optional) (default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public ulong? Gas { get; set; } - - /// - /// (Optional) Integer of the gas price used for each paid gas - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public ulong? GasPrice { get; set; } - - /// - /// (Optional) Integer of the value send with this transaction - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger Value { get; set; } - - /// - /// The compiled code of a contract OR the hash of the invoked method signature and encoded parameters. - /// - [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] - public string Data { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetBlockResponse.cs b/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetBlockResponse.cs deleted file mode 100644 index cf285457ad..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetBlockResponse.cs +++ /dev/null @@ -1,201 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System.Numerics; -using Miningcore.Serialization; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum.DaemonResponses -{ - public class Transaction - { - /// - /// 32 Bytes - hash of the transaction. - /// - public string Hash { get; set; } - - /// - /// the number of transactions made by the sender prior to this one. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong Nonce { get; set; } - - /// - /// 32 Bytes - hash of the block where this transaction was in. null when its pending. - /// - public string BlockHash { get; set; } - - /// - /// block number where this transaction was in. null when its pending. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong? BlockNumber { get; set; } - - /// - /// integer of the transactions index position in the block. null when its pending. - /// - [JsonProperty("transactionIndex")] - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong? Index { get; set; } - - /// - /// address of the sender. - /// - public string From { get; set; } - - /// - /// address of the receiver. null when its a contract creation transaction. - /// - public string To { get; set; } - - /// - /// Value transferred in Wei - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger Value { get; set; } - - /// - /// gas price provided by the sender in Wei. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger GasPrice { get; set; } - - /// - /// gas provided by the sender - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger Gas { get; set; } - - /// - /// the data send along with the transaction. - /// - public string Input { get; set; } - } - - public class Block - { - /// - /// The block number. null when its pending block. - /// - [JsonProperty("number")] - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong? Height { get; set; } - - /// - /// 32 Bytes - hash of the block. null when its pending block. - /// - public string Hash { get; set; } - - /// - /// 32 Bytes - hash of the parent block. - /// - public string ParentHash { get; set; } - - /// - /// 8 Bytes - hash of the generated proof-of-work. null when its pending block. - /// - public string Nonce { get; set; } - - /// - /// An array containing all engine specific fields - /// https://github.com/ethereum/EIPs/issues/95 - /// - public string[] SealFields { get; set; } - - /// - /// 32 Bytes - SHA3 of the uncles data in the block. - /// - public string Sha3Uncles { get; set; } - - /// - /// 256 Bytes - the bloom filter for the logs of the block. null when its pending block. - /// - public string LogsBloom { get; set; } - - /// - /// 32 Bytes - the root of the transaction trie of the block. - /// - public string TransactionsRoot { get; set; } - - /// - /// 32 Bytes - the root of the final state trie of the block. - /// - public string StateRoot { get; set; } - - /// - /// 32 Bytes - the root of the receipts trie of the block. - /// - public string ReceiptsRoot { get; set; } - - /// - /// 20 Bytes - the address of the beneficiary to whom the mining rewards were given. - /// - public string Miner { get; set; } - - /// - /// integer of the difficulty for this block - /// - public string Difficulty { get; set; } - - /// - /// integer of the total difficulty of the chain until this block. - /// - public string TotalDifficulty { get; set; } - - /// - /// the "extra data" field of this block - /// - public string ExtraData { get; set; } - - /// - /// integer the size of this block in bytes - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong Size { get; set; } - - /// - /// the maximum gas allowed in this block - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong GasLimit { get; set; } - - /// - /// the total used gas by all transactions in this block. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong GasUsed { get; set; } - - /// - /// the unix timestamp for when the block was collated. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong Timestamp { get; set; } - - /// - /// Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter. - /// - public Transaction[] Transactions { get; set; } - - /// - /// Array of uncle hashes. - /// - public string[] Uncles { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetSyncStateResponse.cs b/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetSyncStateResponse.cs deleted file mode 100644 index 6ef91ecb93..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetSyncStateResponse.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using Miningcore.Serialization; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum.DaemonResponses -{ - public class SyncState - { - /// - /// The block at which the import started (will only be reset, after the sync reached his head) - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong StartingBlock { get; set; } - - /// - /// The current block, same as eth_blockNumber - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong CurrentBlock { get; set; } - - /// - /// The estimated highest block - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong HighestBlock { get; set; } - - /// - /// Parity: Total amount of snapshot chunks - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong WarpChunksAmount { get; set; } - - /// - /// Parity: Total amount of snapshot chunks - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong WarpChunksProcessed { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetTransactionReceiptResponse.cs b/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetTransactionReceiptResponse.cs deleted file mode 100644 index ce78e56984..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/GetTransactionReceiptResponse.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System.Numerics; -using Miningcore.Serialization; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum.DaemonResponses -{ - public class TransactionReceipt - { - /// - /// 32 Bytes - hash of the transaction. - /// - public string TransactionHash { get; set; } - - /// - /// integer of the transactions index position in the block. null when its pending. - /// - [JsonProperty("transactionIndex")] - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong Index { get; set; } - - /// - /// 32 Bytes - hash of the block where this transaction was in. null when its pending. - /// - public string BlockHash { get; set; } - - /// - /// block number where this transaction was in. null when its pending. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public ulong BlockNumber { get; set; } - - /// - /// The total amount of gas used when this transaction was executed in the block. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger CummulativeGasUsed { get; set; } - - /// - /// The amount of gas used by this specific transaction alone. - /// - [JsonConverter(typeof(HexToIntegralTypeJsonConverter))] - public BigInteger GasUsed { get; set; } - - /// - /// The contract address created, if the transaction was a contract creation, otherwise null. - /// - public string ContractAddress { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/PubSubResponse.cs b/src/Miningcore/Blockchain/Ethereum/DaemonResponses/PubSubResponse.cs deleted file mode 100644 index 98754ee508..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/DaemonResponses/PubSubResponse.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Miningcore.Blockchain.Ethereum.DaemonResponses -{ - public class PubSubParams - { - public string Subscription { get; set; } - public T Result { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumBlockTemplate.cs b/src/Miningcore/Blockchain/Ethereum/EthereumBlockTemplate.cs deleted file mode 100644 index 07ee6c7176..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumBlockTemplate.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Numerics; -using System.Text; -using NBitcoin; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumBlockTemplate - { - /// - /// The block number - /// - public ulong Height { get; set; } - - /// - /// current block header pow-hash (32 Bytes) - /// - public string Header { get; set; } - - /// - /// the seed hash used for the DAG. (32 Bytes) - /// - public string Seed { get; set; } - - /// - /// the boundary condition ("target"), 2^256 / difficulty. (32 Bytes) - /// - public string Target { get; set; } - - /// - /// integer of the difficulty for this block - /// - public ulong Difficulty { get; set; } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumConstants.cs b/src/Miningcore/Blockchain/Ethereum/EthereumConstants.cs deleted file mode 100644 index e651a6f89a..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumConstants.cs +++ /dev/null @@ -1,113 +0,0 @@ -using System; -using System.Numerics; -using System.Text.RegularExpressions; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumConstants - { - public const ulong EpochLength = 30000; - public const ulong CacheSizeForTesting = 1024; - public const ulong DagSizeForTesting = 1024 * 32; - public static BigInteger BigMaxValue = BigInteger.Pow(2, 256); - public static double Pow2x32 = Math.Pow(2, 32); - public static BigInteger BigPow2x32 = new BigInteger(Pow2x32); - public const int AddressLength = 20; - public const decimal Wei = 1000000000000000000; - public static BigInteger WeiBig = new BigInteger(1000000000000000000); - public const string EthereumStratumVersion = "EthereumStratum/1.0.0"; - public const decimal StaticTransactionFeeReserve = 0.0025m; // in ETH - public const string BlockTypeUncle = "uncle"; - -#if !DEBUG - public const int MinPayoutPeerCount = 1; -#else - public const int MinPayoutPeerCount = 1; -#endif - - public static readonly Regex ValidAddressPattern = new Regex("^0x[0-9a-fA-F]{40}$", RegexOptions.Compiled); - public static readonly Regex ZeroHashPattern = new Regex("^0?x?0+$", RegexOptions.Compiled); - public static readonly Regex NoncePattern = new Regex("^0x[0-9a-f]{16}$", RegexOptions.Compiled); - public static readonly Regex HashPattern = new Regex("^0x[0-9a-f]{64}$", RegexOptions.Compiled); - public static readonly Regex WorkerPattern = new Regex("^[0-9a-zA-Z-_]{1,8}$", RegexOptions.Compiled); - - public const ulong ByzantiumHardForkHeight = 4370000; - public const ulong ConstantinopleHardForkHeight = 7280000; - public const decimal HomesteadBlockReward = 5.0m; - public const decimal ByzantiumBlockReward = 3.0m; - public const decimal ConstantinopleReward = 2.0m; - public const decimal TestnetBlockReward = 3.0m; - public const decimal ExpanseBlockReward = 8.0m; - public const decimal EllaismBlockReward = 5.0m; - - public const int MinConfimations = 16; - } - - public class EthereumClassicConstants - { - public const decimal BaseRewardInitial = 5; - public const decimal BasePercent = 0.8m; - public const int BlockPerEra = 5000000; - public const decimal UnclePercent = 0.03125m; - } - - public class CallistoConstants - { - public const decimal BaseRewardInitial = 600; - public const decimal TreasuryPercent = 0.3m; - } - - public enum EthereumNetworkType - { - Main = 1, - Morden = 2, - Ropsten = 3, - Rinkeby = 4, - Kovan = 42, - Galilei = 7919, // Callisto v3 Testnet - - Unknown = -1, - } - - public enum ParityChainType - { - Foundation, - Olympic, - Frontier, - Homestead, - Mainnet, - Morden, - Ropsten, - Classic, - Expanse, - Ellaism, - CallistoTestnet, // Callisto (CLO) v3 Testnet - Callisto, // Callisto (CLO) v3 Testnet - - Unknown = -1, - } - - public static class EthCommands - { - public const string GetWork = "eth_getWork"; - public const string SubmitWork = "eth_submitWork"; - public const string Sign = "eth_sign"; - public const string GetNetVersion = "net_version"; - public const string GetClientVersion = "web3_clientVersion"; - public const string GetCoinbase = "eth_coinbase"; - public const string GetAccounts = "eth_accounts"; - public const string GetPeerCount = "net_peerCount"; - public const string GetSyncState = "eth_syncing"; - public const string GetBlockByNumber = "eth_getBlockByNumber"; - public const string GetBlockByHash = "eth_getBlockByHash"; - public const string GetUncleByBlockNumberAndIndex = "eth_getUncleByBlockNumberAndIndex"; - public const string GetTxReceipt = "eth_getTransactionReceipt"; - public const string SendTx = "eth_sendTransaction"; - public const string UnlockAccount = "personal_unlockAccount"; - public const string Subscribe = "eth_subscribe"; - - public const string ParityVersion = "parity_versionInfo"; - public const string ParityChain = "parity_chain"; - public const string ParitySubscribe = "parity_subscribe"; - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumExtraNonceProvider.cs b/src/Miningcore/Blockchain/Ethereum/EthereumExtraNonceProvider.cs deleted file mode 100644 index befd99cc1c..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumExtraNonceProvider.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; -using Miningcore.Extensions; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumExtraNonceProvider : ExtraNonceProviderBase - { - public EthereumExtraNonceProvider() : base(2) - { - } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumJob.cs b/src/Miningcore/Blockchain/Ethereum/EthereumJob.cs deleted file mode 100644 index af24ff363d..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumJob.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Numerics; -using System.Threading; -using System.Threading.Tasks; -using Miningcore.Crypto.Hashing.Ethash; -using Miningcore.Extensions; -using Miningcore.Stratum; -using NBitcoin; -using NLog; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumJob - { - public EthereumJob(string id, EthereumBlockTemplate blockTemplate, ILogger logger) - { - Id = id; - BlockTemplate = blockTemplate; - this.logger = logger; - - var target = blockTemplate.Target; - if(target.StartsWith("0x")) - target = target.Substring(2); - - blockTarget = new uint256(target.HexToReverseByteArray()); - } - - private readonly Dictionary> workerNonces = - new Dictionary>(); - - public string Id { get; } - public EthereumBlockTemplate BlockTemplate { get; } - private readonly uint256 blockTarget; - private readonly ILogger logger; - - private void RegisterNonce(StratumClient worker, string nonce) - { - var nonceLower = nonce.ToLower(); - - if(!workerNonces.TryGetValue(worker, out var nonces)) - { - nonces = new HashSet(new[] { nonceLower }); - workerNonces[worker] = nonces; - } - - else - { - if(nonces.Contains(nonceLower)) - throw new StratumException(StratumError.MinusOne, "duplicate share"); - - nonces.Add(nonceLower); - } - } - - public async ValueTask<(Share Share, string FullNonceHex, string HeaderHash, string MixHash)> ProcessShareAsync( - StratumClient worker, string nonce, EthashFull ethash, CancellationToken ct) - { - // duplicate nonce? - lock(workerNonces) - { - RegisterNonce(worker, nonce); - } - - // assemble full-nonce - var context = worker.ContextAs(); - var fullNonceHex = context.ExtraNonce1 + nonce; - - if(!ulong.TryParse(fullNonceHex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var fullNonce)) - throw new StratumException(StratumError.MinusOne, "bad nonce " + fullNonceHex); - - // get dag for block - var dag = await ethash.GetDagAsync(BlockTemplate.Height, logger, ct); - - // compute - if(!dag.Compute(logger, BlockTemplate.Header.HexToByteArray(), fullNonce, out var mixDigest, out var resultBytes)) - throw new StratumException(StratumError.MinusOne, "bad hash"); - - // test if share meets at least workers current difficulty - resultBytes.ReverseInPlace(); - var resultValue = new uint256(resultBytes); - var resultValueBig = resultBytes.AsSpan().ToBigInteger(); - var shareDiff = (double) BigInteger.Divide(EthereumConstants.BigMaxValue, resultValueBig) / EthereumConstants.Pow2x32; - var stratumDifficulty = context.Difficulty; - var ratio = shareDiff / stratumDifficulty; - var isBlockCandidate = resultValue <= blockTarget; - - if(!isBlockCandidate && ratio < 0.99) - { - // check if share matched the previous difficulty from before a vardiff retarget - if(context.VarDiff?.LastUpdate != null && context.PreviousDifficulty.HasValue) - { - ratio = shareDiff / context.PreviousDifficulty.Value; - - if(ratio < 0.99) - throw new StratumException(StratumError.LowDifficultyShare, $"low difficulty share ({shareDiff})"); - - // use previous difficulty - stratumDifficulty = context.PreviousDifficulty.Value; - } - - else - throw new StratumException(StratumError.LowDifficultyShare, $"low difficulty share ({shareDiff})"); - } - - // create share - var share = new Share - { - BlockHeight = (long) BlockTemplate.Height, - IpAddress = worker.RemoteEndpoint?.Address?.ToString(), - Miner = context.Miner, - Worker = context.Worker, - UserAgent = context.UserAgent, - IsBlockCandidate = isBlockCandidate, - Difficulty = stratumDifficulty * EthereumConstants.Pow2x32, - BlockHash = mixDigest.ToHexString(true) - }; - - if(share.IsBlockCandidate) - { - fullNonceHex = "0x" + fullNonceHex; - var headerHash = BlockTemplate.Header; - var mixHash = mixDigest.ToHexString(true); - - share.TransactionConfirmationData = $"{mixDigest.ToHexString(true)}:{fullNonceHex}"; - - return (share, fullNonceHex, headerHash, mixHash); - } - - return (share, null, null, null); - } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumJobManager.cs b/src/Miningcore/Blockchain/Ethereum/EthereumJobManager.cs deleted file mode 100644 index e6f3c48e4c..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumJobManager.cs +++ /dev/null @@ -1,801 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net; -using System.Numerics; -using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Autofac; -using Miningcore.Blockchain.Bitcoin; -using Miningcore.Blockchain.Ethereum.Configuration; -using Miningcore.Blockchain.Ethereum.DaemonResponses; -using Miningcore.Configuration; -using Miningcore.Crypto.Hashing.Ethash; -using Miningcore.DaemonInterface; -using Miningcore.Extensions; -using Miningcore.JsonRpc; -using Miningcore.Messaging; -using Miningcore.Notifications.Messages; -using Miningcore.Stratum; -using Miningcore.Time; -using Miningcore.Util; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NLog; -using Block = Miningcore.Blockchain.Ethereum.DaemonResponses.Block; -using Contract = Miningcore.Contracts.Contract; -using EC = Miningcore.Blockchain.Ethereum.EthCommands; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumJobManager : JobManagerBase - { - public EthereumJobManager( - IComponentContext ctx, - IMasterClock clock, - IMessageBus messageBus, - JsonSerializerSettings serializerSettings) : - base(ctx, messageBus) - { - Contract.RequiresNonNull(ctx, nameof(ctx)); - Contract.RequiresNonNull(clock, nameof(clock)); - Contract.RequiresNonNull(messageBus, nameof(messageBus)); - - this.clock = clock; - - serializer = new JsonSerializer - { - ContractResolver = serializerSettings.ContractResolver - }; - } - - private DaemonEndpointConfig[] daemonEndpoints; - private DaemonClient daemon; - private EthereumNetworkType networkType; - private ParityChainType chainType; - private bool isParity = true; - private EthashFull ethash; - private readonly IMasterClock clock; - private readonly EthereumExtraNonceProvider extraNonceProvider = new EthereumExtraNonceProvider(); - - private const int MaxBlockBacklog = 3; - protected readonly Dictionary validJobs = new Dictionary(); - private EthereumPoolConfigExtra extraPoolConfig; - private readonly JsonSerializer serializer; - - protected async Task UpdateJobAsync() - { - logger.LogInvoke(); - - try - { - return UpdateJob(await GetBlockTemplateAsync()); - } - - catch(Exception ex) - { - logger.Error(ex, () => $"Error during {nameof(UpdateJobAsync)}"); - } - - return false; - } - - protected bool UpdateJob(EthereumBlockTemplate blockTemplate) - { - logger.LogInvoke(); - - try - { - // may happen if daemon is currently not connected to peers - if(blockTemplate == null || blockTemplate.Header?.Length == 0) - return false; - - // logger.Info(() => $"Blocktemplate {blockTemplate.Height}-{blockTemplate.Header}"); - - var job = currentJob; - var isNew = currentJob == null || - job.BlockTemplate.Height < blockTemplate.Height || - job.BlockTemplate.Header != blockTemplate.Header; - - if(isNew) - { - messageBus.NotifyChainHeight(poolConfig.Id, blockTemplate.Height, poolConfig.Template); - - var jobId = NextJobId("x8"); - - // update template - job = new EthereumJob(jobId, blockTemplate, logger); - - lock(jobLock) - { - // add jobs - validJobs[jobId] = job; - - // remove old ones - var obsoleteKeys = validJobs.Keys - .Where(key => validJobs[key].BlockTemplate.Height < job.BlockTemplate.Height - MaxBlockBacklog).ToArray(); - - foreach(var key in obsoleteKeys) - validJobs.Remove(key); - } - - currentJob = job; - - // update stats - BlockchainStats.LastNetworkBlockTime = clock.Now; - BlockchainStats.BlockHeight = job.BlockTemplate.Height; - BlockchainStats.NetworkDifficulty = job.BlockTemplate.Difficulty; - BlockchainStats.NextNetworkTarget = job.BlockTemplate.Target; - BlockchainStats.NextNetworkBits = ""; - } - - return isNew; - } - - catch(Exception ex) - { - logger.Error(ex, () => $"Error during {nameof(UpdateJob)}"); - } - - return false; - } - - private Task GetBlockTemplateAsync() - { - if(isParity) - return GetBlockTemplateParityAsync(); - - return GetBlockTemplateGethAsync(); - } - - private async Task GetBlockTemplateParityAsync() - { - logger.LogInvoke(); - - var response = await daemon.ExecuteCmdAnyAsync(logger, EC.GetWork); - - if(response.Error != null) - { - logger.Warn(() => $"Error(s) refreshing blocktemplate: {response.Error})"); - return null; - } - - if(response.Response == null) - { - logger.Warn(() => $"Error(s) refreshing blocktemplate: {EC.GetWork} returned null response"); - return null; - } - - // extract results - var work = response.Response.ToObject(); - var result = AssembleBlockTemplate(work); - - return result; - } - - private async Task GetBlockTemplateGethAsync() - { - logger.LogInvoke(); - - var commands = new[] - { - new DaemonCmd(EC.GetWork), - new DaemonCmd(EC.GetBlockByNumber, new[] { (object) "latest", true }) - }; - - var results = await daemon.ExecuteBatchAnyAsync(logger, commands); - - if(results.Any(x => x.Error != null)) - { - logger.Warn(() => $"Error(s) refreshing blocktemplate: {results.First(x => x.Error != null).Error.Message}"); - return null; - } - - // extract results - var work = results[0].Response.ToObject(); - var block = results[1].Response.ToObject(); - - // append blockheight (parity returns this as 4th element in the getWork response, geth does not) - if(work.Length < 4) - { - var currentHeight = block.Height.Value; - work = work.Concat(new[] { (currentHeight + 1).ToStringHexWithPrefix() }).ToArray(); - } - - var result = AssembleBlockTemplate(work); - return result; - } - - private EthereumBlockTemplate AssembleBlockTemplate(string[] work) - { - if(work.Length < 4) - { - logger.Error(() => $"Error(s) refreshing blocktemplate: getWork did not return blockheight. Are you really connected to a Parity daemon?"); - return null; - } - - // extract values - var height = work[3].IntegralFromHex(); - var targetString = work[2]; - var target = BigInteger.Parse(targetString.Substring(2), NumberStyles.HexNumber); - - var result = new EthereumBlockTemplate - { - Header = work[0], - Seed = work[1], - Target = targetString, - Difficulty = (ulong) BigInteger.Divide(EthereumConstants.BigMaxValue, target), - Height = height, - }; - - return result; - } - - private async Task ShowDaemonSyncProgressAsync() - { - var responses = await daemon.ExecuteCmdAllAsync(logger, EC.GetSyncState); - var firstValidResponse = responses.FirstOrDefault(x => x.Error == null && x.Response != null)?.Response; - - if(firstValidResponse != null) - { - // eth_syncing returns false if not synching - if(firstValidResponse is bool) - return; - - var syncStates = responses.Where(x => x.Error == null && x.Response != null && firstValidResponse is JObject) - .Select(x => ((JObject) x.Response).ToObject()) - .ToArray(); - - if(syncStates.Any()) - { - // get peer count - var response = await daemon.ExecuteCmdAllAsync(logger, EC.GetPeerCount); - var validResponses = response.Where(x => x.Error == null && x.Response != null).ToArray(); - var peerCount = validResponses.Any() ? validResponses.Max(x => x.Response.IntegralFromHex()) : 0; - - if(syncStates.Any(x => x.WarpChunksAmount != 0)) - { - var warpChunkAmount = syncStates.Min(x => x.WarpChunksAmount); - var warpChunkProcessed = syncStates.Max(x => x.WarpChunksProcessed); - var percent = (double) warpChunkProcessed / warpChunkAmount * 100; - - logger.Info(() => $"Daemons have downloaded {percent:0.00}% of warp-chunks from {peerCount} peers"); - } - - else if(syncStates.Any(x => x.HighestBlock != 0)) - { - var lowestHeight = syncStates.Min(x => x.CurrentBlock); - var totalBlocks = syncStates.Max(x => x.HighestBlock); - var percent = (double) lowestHeight / totalBlocks * 100; - - logger.Info(() => $"Daemons have downloaded {percent:0.00}% of blockchain from {peerCount} peers"); - } - } - } - } - - private async Task UpdateNetworkStatsAsync() - { - logger.LogInvoke(); - - try - { - var commands = new[] - { - new DaemonCmd(EC.GetPeerCount), - }; - - var results = await daemon.ExecuteBatchAnyAsync(logger, commands); - - if(results.Any(x => x.Error != null)) - { - var errors = results.Where(x => x.Error != null) - .ToArray(); - - if(errors.Any()) - logger.Warn(() => $"Error(s) refreshing network stats: {string.Join(", ", errors.Select(y => y.Error.Message))})"); - } - - // extract results - var peerCount = results[0].Response.ToObject().IntegralFromHex(); - - BlockchainStats.NetworkHashrate = 0; // TODO - BlockchainStats.ConnectedPeers = peerCount; - } - - catch(Exception e) - { - logger.Error(e); - } - } - - private async Task SubmitBlockAsync(Share share, string fullNonceHex, string headerHash, string mixHash) - { - // submit work - var response = await daemon.ExecuteCmdAnyAsync(logger, EC.SubmitWork, new[] - { - fullNonceHex, - headerHash, - mixHash - }); - - if(response.Error != null || (bool?) response.Response == false) - { - var error = response.Error?.Message ?? response?.Response?.ToString(); - - logger.Warn(() => $"Block {share.BlockHeight} submission failed with: {error}"); - messageBus.SendMessage(new AdminNotification("Block submission failed", $"Pool {poolConfig.Id} {(!string.IsNullOrEmpty(share.Source) ? $"[{share.Source.ToUpper()}] " : string.Empty)}failed to submit block {share.BlockHeight}: {error}")); - - return false; - } - - return true; - } - - private object[] GetJobParamsForStratum(bool isNew) - { - var job = currentJob; - - if(job != null) - { - return new object[] - { - job.Id, - job.BlockTemplate.Seed.StripHexPrefix(), - job.BlockTemplate.Header.StripHexPrefix(), - isNew - }; - } - - return new object[0]; - } - - private JsonRpcRequest DeserializeRequest(byte[] data) - { - using(var stream = new MemoryStream(data)) - { - using(var reader = new StreamReader(stream, Encoding.UTF8)) - { - using(var jreader = new JsonTextReader(reader)) - { - return serializer.Deserialize(jreader); - } - } - } - } - - #region API-Surface - - public IObservable Jobs { get; private set; } - - public override void Configure(PoolConfig poolConfig, ClusterConfig clusterConfig) - { - extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs(); - - // extract standard daemon endpoints - daemonEndpoints = poolConfig.Daemons - .Where(x => string.IsNullOrEmpty(x.Category)) - .ToArray(); - - base.Configure(poolConfig, clusterConfig); - - if(poolConfig.EnableInternalStratum == true) - { - // ensure dag location is configured - var dagDir = !string.IsNullOrEmpty(extraPoolConfig?.DagDir) ? - Environment.ExpandEnvironmentVariables(extraPoolConfig.DagDir) : - Dag.GetDefaultDagDirectory(); - - // create it if necessary - Directory.CreateDirectory(dagDir); - - // setup ethash - ethash = new EthashFull(3, dagDir); - } - } - - public bool ValidateAddress(string address) - { - Contract.Requires(!string.IsNullOrEmpty(address), $"{nameof(address)} must not be empty"); - - if(EthereumConstants.ZeroHashPattern.IsMatch(address) || - !EthereumConstants.ValidAddressPattern.IsMatch(address)) - return false; - - return true; - } - - public void PrepareWorker(StratumClient client) - { - var context = client.ContextAs(); - context.ExtraNonce1 = extraNonceProvider.Next(); - } - - public async ValueTask SubmitShareAsync(StratumClient worker, string[] request, CancellationToken ct) - { - Contract.RequiresNonNull(worker, nameof(worker)); - Contract.RequiresNonNull(request, nameof(request)); - - logger.LogInvoke(new[] { worker.ConnectionId }); - var context = worker.ContextAs(); - - // var miner = request[0]; - var jobId = request[1]; - var nonce = request[2]; - EthereumJob job; - - // stale? - lock(jobLock) - { - if(!validJobs.TryGetValue(jobId, out job)) - throw new StratumException(StratumError.MinusOne, "stale share"); - } - - // validate & process - var (share, fullNonceHex, headerHash, mixHash) = await job.ProcessShareAsync(worker, nonce, ethash, ct); - - // enrich share with common data - share.PoolId = poolConfig.Id; - share.NetworkDifficulty = BlockchainStats.NetworkDifficulty; - share.Source = clusterConfig.ClusterName; - share.Created = clock.Now; - - // if block candidate, submit & check if accepted by network - if(share.IsBlockCandidate) - { - logger.Info(() => $"Submitting block {share.BlockHeight}"); - - share.IsBlockCandidate = await SubmitBlockAsync(share, fullNonceHex, headerHash, mixHash); - - if(share.IsBlockCandidate) - { - logger.Info(() => $"Daemon accepted block {share.BlockHeight} submitted by {context.Miner}"); - } - } - - return share; - } - - public BlockchainStats BlockchainStats { get; } = new BlockchainStats(); - - #endregion // API-Surface - - #region Overrides - - protected override void ConfigureDaemons() - { - var jsonSerializerSettings = ctx.Resolve(); - - daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); - daemon.Configure(daemonEndpoints); - } - - protected override async Task AreDaemonsHealthyAsync() - { - var responses = await daemon.ExecuteCmdAllAsync(logger, EC.GetBlockByNumber, new[] { (object) "latest", true }); - - if(responses.Where(x => x.Error?.InnerException?.GetType() == typeof(DaemonClientException)) - .Select(x => (DaemonClientException) x.Error.InnerException) - .Any(x => x.Code == HttpStatusCode.Unauthorized)) - logger.ThrowLogPoolStartupException($"Daemon reports invalid credentials"); - - return responses.All(x => x.Error == null); - } - - protected override async Task AreDaemonsConnectedAsync() - { - var response = await daemon.ExecuteCmdAnyAsync(logger, EC.GetPeerCount); - - return response.Error == null && response.Response.IntegralFromHex() > 0; - } - - protected override async Task EnsureDaemonsSynchedAsync(CancellationToken ct) - { - var syncPendingNotificationShown = false; - - while(true) - { - var responses = await daemon.ExecuteCmdAllAsync(logger, EC.GetSyncState); - - var isSynched = responses.All(x => x.Error == null && - x.Response is bool && (bool) x.Response == false); - - if(isSynched) - { - logger.Info(() => $"All daemons synched with blockchain"); - break; - } - - if(!syncPendingNotificationShown) - { - logger.Info(() => $"Daemons still syncing with network. Manager will be started once synced"); - syncPendingNotificationShown = true; - } - - await ShowDaemonSyncProgressAsync(); - - // delay retry by 5s - await Task.Delay(5000, ct); - } - } - - protected override async Task PostStartInitAsync(CancellationToken ct) - { - var commands = new[] - { - new DaemonCmd(EC.GetNetVersion), - new DaemonCmd(EC.GetAccounts), - new DaemonCmd(EC.GetCoinbase), - new DaemonCmd(EC.ParityChain), - }; - - var results = await daemon.ExecuteBatchAnyAsync(logger, commands); - - if(results.Any(x => x.Error != null)) - { - if(results[3].Error != null) - isParity = false; - - var errors = results.Take(3).Where(x => x.Error != null) - .ToArray(); - - if(errors.Any()) - logger.ThrowLogPoolStartupException($"Init RPC failed: {string.Join(", ", errors.Select(y => y.Error.Message))}"); - } - - // extract results - var netVersion = results[0].Response.ToObject(); - var accounts = results[1].Response.ToObject(); - var coinbase = results[2].Response.ToObject(); - var parityChain = isParity ? - results[3].Response.ToObject() : - (extraPoolConfig?.ChainTypeOverride ?? "Mainnet"); - - // ensure pool owns wallet - //if (clusterConfig.PaymentProcessing?.Enabled == true && !accounts.Contains(poolConfig.Address) || coinbase != poolConfig.Address) - // logger.ThrowLogPoolStartupException($"Daemon does not own pool-address '{poolConfig.Address}'", LogCat); - - EthereumUtils.DetectNetworkAndChain(netVersion, parityChain, out networkType, out chainType); - - if(clusterConfig.PaymentProcessing?.Enabled == true && poolConfig.PaymentProcessing?.Enabled == true) - ConfigureRewards(); - - // update stats - BlockchainStats.RewardType = "POW"; - BlockchainStats.NetworkType = $"{chainType}-{networkType}"; - - await UpdateNetworkStatsAsync(); - - // Periodically update network stats - Observable.Interval(TimeSpan.FromMinutes(10)) - .Select(via => Observable.FromAsync(async () => - { - try - { - await UpdateNetworkStatsAsync(); - } - - catch(Exception ex) - { - logger.Error(ex); - } - })) - .Concat() - .Subscribe(); - - if(poolConfig.EnableInternalStratum == true) - { - // make sure we have a current DAG - while(true) - { - var blockTemplate = await GetBlockTemplateAsync(); - - if(blockTemplate != null) - { - logger.Info(() => $"Loading current DAG ..."); - - await ethash.GetDagAsync(blockTemplate.Height, logger, ct); - - logger.Info(() => $"Loaded current DAG"); - break; - } - - logger.Info(() => $"Waiting for first valid block template"); - await Task.Delay(TimeSpan.FromSeconds(5), ct); - } - } - - await SetupJobUpdatesAsync(); - } - - private void ConfigureRewards() - { - // Donation to MiningCore development - if(networkType == EthereumNetworkType.Main && - chainType == ParityChainType.Mainnet && - DevDonation.Addresses.TryGetValue(poolConfig.Template.As().Symbol, out var address)) - { - poolConfig.RewardRecipients = poolConfig.RewardRecipients.Concat(new[] - { - new RewardRecipient - { - Address = address, - Percentage = DevDonation.Percent, - Type = "dev" - } - }).ToArray(); - } - } - - protected virtual async Task SetupJobUpdatesAsync() - { - if(extraPoolConfig?.BtStream == null) - { - var enableStreaming = extraPoolConfig?.EnableDaemonWebsocketStreaming == true; - - if(enableStreaming && !poolConfig.Daemons.Any(x => - x.Extra.SafeExtensionDataAs()?.PortWs.HasValue == true)) - { - logger.Warn(() => $"'{nameof(EthereumPoolConfigExtra.EnableDaemonWebsocketStreaming).ToLowerCamelCase()}' enabled but not a single daemon found with a configured websocket port ('{nameof(EthereumDaemonEndpointConfigExtra.PortWs).ToLowerCamelCase()}'). Falling back to polling."); - enableStreaming = false; - } - - if(enableStreaming) - { - // collect ports - var wsDaemons = poolConfig.Daemons - .Where(x => x.Extra.SafeExtensionDataAs()?.PortWs.HasValue == true) - .ToDictionary(x => x, x => - { - var extra = x.Extra.SafeExtensionDataAs(); - - return (extra.PortWs.Value, extra.HttpPathWs, extra.SslWs); - }); - - logger.Info(() => $"Subscribing to WebSocket(s) {string.Join(", ", wsDaemons.Keys.Select(x => $"{(wsDaemons[x].SslWs ? "wss" : "ws")}://{x.Host}:{wsDaemons[x].Value}").Distinct())}"); - - if(isParity) - { - // stream work updates - var getWorkObs = daemon.WebsocketSubscribe(logger, wsDaemons, EC.ParitySubscribe, new[] { (object) EC.GetWork }) - .Select(data => - { - try - { - var psp = DeserializeRequest(data).ParamsAs>(); - return psp?.Result; - } - - catch(Exception ex) - { - logger.Info(() => $"Error deserializing pending block: {ex.Message}"); - } - - return null; - }); - - Jobs = getWorkObs.Where(x => x != null) - .Select(AssembleBlockTemplate) - .Select(UpdateJob) - .Do(isNew => - { - if(isNew) - logger.Info(() => $"New work at height {currentJob.BlockTemplate.Height} and header {currentJob.BlockTemplate.Header} detected [{JobRefreshBy.WebSocket}]"); - }) - .Where(isNew => isNew) - .Select(_ => GetJobParamsForStratum(true)) - .Publish() - .RefCount(); - } - - else - { - var wsSubscription = "newHeads"; - var isRetry = false; - retry: - - // stream work updates - var getWorkObs = daemon.WebsocketSubscribe(logger, wsDaemons, EC.Subscribe, new[] { (object) wsSubscription, new object() }); - - // test subscription - var subcriptionResponse = await getWorkObs - .Take(1) - .Select(x => JsonConvert.DeserializeObject>(Encoding.UTF8.GetString(x))) - .ToTask(); - - if(subcriptionResponse.Error != null) - { - // older versions of geth only support subscriptions to "newBlocks" - if(!isRetry && subcriptionResponse.Error.Code == (int) BitcoinRPCErrorCode.RPC_METHOD_NOT_FOUND) - { - wsSubscription = "newBlocks"; - - isRetry = true; - goto retry; - } - - logger.ThrowLogPoolStartupException($"Unable to subscribe to geth websocket '{wsSubscription}': {subcriptionResponse.Error.Message} [{subcriptionResponse.Error.Code}]"); - } - - Jobs = getWorkObs.Where(x => x != null) - .Select(_ => Observable.FromAsync(UpdateJobAsync)) - .Concat() - .Do(isNew => - { - if(isNew) - logger.Info(() => $"New work at height {currentJob.BlockTemplate.Height} and header {currentJob.BlockTemplate.Header} detected [WS]"); - }) - .Where(isNew => isNew) - .Select(_ => GetJobParamsForStratum(true)) - .Publish() - .RefCount(); - } - } - - else - { - var pollingInterval = poolConfig.BlockRefreshInterval > 0 ? poolConfig.BlockRefreshInterval : 1000; - - Jobs = Observable.Interval(TimeSpan.FromMilliseconds(pollingInterval)) - .Select(_ => Observable.FromAsync(UpdateJobAsync)) - .Concat() - .Do(isNew => - { - if(isNew) - logger.Info(() => $"New work at height {currentJob.BlockTemplate.Height} and header {currentJob.BlockTemplate.Header} detected [{JobRefreshBy.Poll}]"); - }) - .Where(isNew => isNew) - .Select(_ => GetJobParamsForStratum(true)) - .Publish() - .RefCount(); - } - } - - else - { - var btStream = BtStreamSubscribe(extraPoolConfig.BtStream); - - Jobs = btStream.Where(x => x != null) - .Select(JsonConvert.DeserializeObject) - .Select(AssembleBlockTemplate) - .Select(UpdateJob) - .Do(isNew => - { - if(isNew) - logger.Info(() => $"New work at height {currentJob.BlockTemplate.Height} and header {currentJob.BlockTemplate.Header} detected [{JobRefreshBy.BlockTemplateStream}]"); - }) - .Where(isNew => isNew) - .Select(_ => GetJobParamsForStratum(true)) - .Publish() - .RefCount(); - } - } - - #endregion // Overrides - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumPayoutHandler.cs b/src/Miningcore/Blockchain/Ethereum/EthereumPayoutHandler.cs deleted file mode 100644 index 4ac83efe09..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumPayoutHandler.cs +++ /dev/null @@ -1,488 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System; -using System.Collections.Generic; -using System.Data; -using System.Globalization; -using System.Linq; -using System.Numerics; -using System.Threading.Tasks; -using Autofac; -using AutoMapper; -using Miningcore.Blockchain.Ethereum.Configuration; -using Miningcore.Blockchain.Ethereum.DaemonRequests; -using Miningcore.Blockchain.Ethereum.DaemonResponses; -using Miningcore.Configuration; -using Miningcore.DaemonInterface; -using Miningcore.Extensions; -using Miningcore.Messaging; -using Miningcore.Notifications; -using Miningcore.Notifications.Messages; -using Miningcore.Payments; -using Miningcore.Persistence; -using Miningcore.Persistence.Model; -using Miningcore.Persistence.Repositories; -using Miningcore.Time; -using Miningcore.Util; -using Newtonsoft.Json; -using Block = Miningcore.Persistence.Model.Block; -using Contract = Miningcore.Contracts.Contract; -using EC = Miningcore.Blockchain.Ethereum.EthCommands; - -namespace Miningcore.Blockchain.Ethereum -{ - [CoinFamily(CoinFamily.Ethereum)] - public class EthereumPayoutHandler : PayoutHandlerBase, - IPayoutHandler - { - public EthereumPayoutHandler( - IComponentContext ctx, - IConnectionFactory cf, - IMapper mapper, - IShareRepository shareRepo, - IBlockRepository blockRepo, - IBalanceRepository balanceRepo, - IPaymentRepository paymentRepo, - IMasterClock clock, - IMessageBus messageBus) : - base(cf, mapper, shareRepo, blockRepo, balanceRepo, paymentRepo, clock, messageBus) - { - Contract.RequiresNonNull(ctx, nameof(ctx)); - Contract.RequiresNonNull(balanceRepo, nameof(balanceRepo)); - Contract.RequiresNonNull(paymentRepo, nameof(paymentRepo)); - - this.ctx = ctx; - } - - private readonly IComponentContext ctx; - private DaemonClient daemon; - private EthereumNetworkType networkType; - private ParityChainType chainType; - private const int BlockSearchOffset = 50; - private EthereumPoolConfigExtra extraPoolConfig; - private EthereumPoolPaymentProcessingConfigExtra extraConfig; - private bool isParity = true; - - protected override string LogCategory => "Ethereum Payout Handler"; - - #region IPayoutHandler - - public async Task ConfigureAsync(ClusterConfig clusterConfig, PoolConfig poolConfig) - { - this.poolConfig = poolConfig; - this.clusterConfig = clusterConfig; - extraPoolConfig = poolConfig.Extra.SafeExtensionDataAs(); - extraConfig = poolConfig.PaymentProcessing.Extra.SafeExtensionDataAs(); - - logger = LogUtil.GetPoolScopedLogger(typeof(EthereumPayoutHandler), poolConfig); - - // configure standard daemon - var jsonSerializerSettings = ctx.Resolve(); - - var daemonEndpoints = poolConfig.Daemons - .Where(x => string.IsNullOrEmpty(x.Category)) - .ToArray(); - - daemon = new DaemonClient(jsonSerializerSettings, messageBus, clusterConfig.ClusterName ?? poolConfig.PoolName, poolConfig.Id); - daemon.Configure(daemonEndpoints); - - await DetectChainAsync(); - } - - public async Task ClassifyBlocksAsync(Block[] blocks) - { - Contract.RequiresNonNull(poolConfig, nameof(poolConfig)); - Contract.RequiresNonNull(blocks, nameof(blocks)); - - var coin = poolConfig.Template.As(); - var pageSize = 100; - var pageCount = (int) Math.Ceiling(blocks.Length / (double) pageSize); - var blockCache = new Dictionary(); - var result = new List(); - - for(var i = 0; i < pageCount; i++) - { - // get a page full of blocks - var page = blocks - .Skip(i * pageSize) - .Take(pageSize) - .ToArray(); - - // get latest block - var latestBlockResponses = await daemon.ExecuteCmdAllAsync(logger, EC.GetBlockByNumber, new[] { (object) "latest", true }); - var latestBlockHeight = latestBlockResponses.First(x => x.Error == null && x.Response?.Height != null).Response.Height.Value; - - // execute batch - var blockInfos = await FetchBlocks(blockCache, page.Select(block => (long) block.BlockHeight).ToArray()); - - for(var j = 0; j < blockInfos.Length; j++) - { - var blockInfo = blockInfos[j]; - var block = page[j]; - - // extract confirmation data from stored block - var mixHash = block.TransactionConfirmationData.Split(":").First(); - var nonce = block.TransactionConfirmationData.Split(":").Last(); - - // update progress - block.ConfirmationProgress = Math.Min(1.0d, (double) (latestBlockHeight - block.BlockHeight) / EthereumConstants.MinConfimations); - result.Add(block); - - messageBus.NotifyBlockConfirmationProgress(poolConfig.Id, block, coin); - - // is it block mined by us? - if(string.Equals(blockInfo.Miner, poolConfig.Address, StringComparison.OrdinalIgnoreCase)) - { - // additional check - // NOTE: removal of first character of both sealfields caused by - // https://github.com/paritytech/parity/issues/1090 - var match = isParity ? - true : - blockInfo.SealFields[0].Substring(2) == mixHash && - blockInfo.SealFields[1].Substring(2) == nonce; - - // mature? - if(match && (latestBlockHeight - block.BlockHeight >= EthereumConstants.MinConfimations)) - { - block.Status = BlockStatus.Confirmed; - block.ConfirmationProgress = 1; - block.BlockHeight = (ulong) blockInfo.Height; - block.Reward = GetBaseBlockReward(chainType, block.BlockHeight); // base reward - block.Type = "block"; - - if(extraConfig?.KeepUncles == false) - block.Reward += blockInfo.Uncles.Length * (block.Reward / 32); // uncle rewards - - if(extraConfig?.KeepTransactionFees == false && blockInfo.Transactions?.Length > 0) - block.Reward += await GetTxRewardAsync(blockInfo); // tx fees - - logger.Info(() => $"[{LogCategory}] Unlocked block {block.BlockHeight} worth {FormatAmount(block.Reward)}"); - - messageBus.NotifyBlockUnlocked(poolConfig.Id, block, coin); - } - - continue; - } - - // search for a block containing our block as an uncle by checking N blocks in either direction - var heightMin = block.BlockHeight - BlockSearchOffset; - var heightMax = Math.Min(block.BlockHeight + BlockSearchOffset, latestBlockHeight); - var range = new List(); - - for(var k = heightMin; k < heightMax; k++) - range.Add((long) k); - - // execute batch - var blockInfo2s = await FetchBlocks(blockCache, range.ToArray()); - - foreach(var blockInfo2 in blockInfo2s) - { - // don't give up yet, there might be an uncle - if(blockInfo2.Uncles.Length > 0) - { - // fetch all uncles in a single RPC batch request - var uncleBatch = blockInfo2.Uncles.Select((x, index) => new DaemonCmd(EC.GetUncleByBlockNumberAndIndex, - new[] { blockInfo2.Height.Value.ToStringHexWithPrefix(), index.ToStringHexWithPrefix() })) - .ToArray(); - - logger.Info(() => $"[{LogCategory}] Fetching {blockInfo2.Uncles.Length} uncles for block {blockInfo2.Height}"); - - var uncleResponses = await daemon.ExecuteBatchAnyAsync(logger, uncleBatch); - - logger.Info(() => $"[{LogCategory}] Fetched {uncleResponses.Count(x => x.Error == null && x.Response != null)} uncles for block {blockInfo2.Height}"); - - var uncle = uncleResponses.Where(x => x.Error == null && x.Response != null) - .Select(x => x.Response.ToObject()) - .FirstOrDefault(x => string.Equals(x.Miner, poolConfig.Address, StringComparison.OrdinalIgnoreCase)); - - if(uncle != null) - { - // mature? - if(latestBlockHeight - uncle.Height.Value >= EthereumConstants.MinConfimations) - { - block.Status = BlockStatus.Confirmed; - block.ConfirmationProgress = 1; - block.Reward = GetUncleReward(chainType, uncle.Height.Value, blockInfo2.Height.Value); - block.BlockHeight = uncle.Height.Value; - block.Type = EthereumConstants.BlockTypeUncle; - - logger.Info(() => $"[{LogCategory}] Unlocked uncle for block {blockInfo2.Height.Value} at height {uncle.Height.Value} worth {FormatAmount(block.Reward)}"); - - messageBus.NotifyBlockUnlocked(poolConfig.Id, block, coin); - } - - else - logger.Info(() => $"[{LogCategory}] Got immature matching uncle for block {blockInfo2.Height.Value}. Will try again."); - - break; - } - } - } - - if(block.Status == BlockStatus.Pending && block.ConfirmationProgress > 0.75) - { - // we've lost this one - block.Status = BlockStatus.Orphaned; - block.Reward = 0; - - messageBus.NotifyBlockUnlocked(poolConfig.Id, block, coin); - } - } - } - - return result.ToArray(); - } - - public Task CalculateBlockEffortAsync(Block block, double accumulatedBlockShareDiff) - { - block.Effort = accumulatedBlockShareDiff / block.NetworkDifficulty; - - return Task.FromResult(true); - } - - public override async Task UpdateBlockRewardBalancesAsync(IDbConnection con, IDbTransaction tx, Block block, PoolConfig pool) - { - var blockRewardRemaining = await base.UpdateBlockRewardBalancesAsync(con, tx, block, pool); - - // Deduct static reserve for tx fees - blockRewardRemaining -= EthereumConstants.StaticTransactionFeeReserve; - - return blockRewardRemaining; - } - - public async Task PayoutAsync(Balance[] balances) - { - // ensure we have peers - var infoResponse = await daemon.ExecuteCmdSingleAsync(logger, EC.GetPeerCount); - - if(networkType == EthereumNetworkType.Main && - (infoResponse.Error != null || string.IsNullOrEmpty(infoResponse.Response) || - infoResponse.Response.IntegralFromHex() < EthereumConstants.MinPayoutPeerCount)) - { - logger.Warn(() => $"[{LogCategory}] Payout aborted. Not enough peers (4 required)"); - return; - } - - var txHashes = new List(); - - foreach(var balance in balances) - { - try - { - var txHash = await PayoutAsync(balance); - txHashes.Add(txHash); - } - - catch(Exception ex) - { - logger.Error(ex); - - NotifyPayoutFailure(poolConfig.Id, new[] { balance }, ex.Message, null); - } - } - - if(txHashes.Any()) - NotifyPayoutSuccess(poolConfig.Id, balances, txHashes.ToArray(), null); - } - - #endregion // IPayoutHandler - - private async Task FetchBlocks(Dictionary blockCache, params long[] blockHeights) - { - var cacheMisses = blockHeights.Where(x => !blockCache.ContainsKey(x)).ToArray(); - - if(cacheMisses.Any()) - { - var blockBatch = cacheMisses.Select(height => new DaemonCmd(EC.GetBlockByNumber, - new[] - { - (object) height.ToStringHexWithPrefix(), - true - })).ToArray(); - - var tmp = await daemon.ExecuteBatchAnyAsync(logger, blockBatch); - - var transformed = tmp - .Where(x => x.Error == null && x.Response != null) - .Select(x => x.Response?.ToObject()) - .Where(x => x != null) - .ToArray(); - - foreach(var block in transformed) - blockCache[(long) block.Height.Value] = block; - } - - return blockHeights.Select(x => blockCache[x]).ToArray(); - } - - internal static decimal GetBaseBlockReward(ParityChainType chainType, ulong height) - { - switch(chainType) - { - case ParityChainType.Mainnet: - if (height >= EthereumConstants.ConstantinopleHardForkHeight) - return EthereumConstants.ConstantinopleReward; - if(height >= EthereumConstants.ByzantiumHardForkHeight) - return EthereumConstants.ByzantiumBlockReward; - - return EthereumConstants.HomesteadBlockReward; - - case ParityChainType.Classic: - { - var era = Math.Floor(((double) height + 1) / EthereumClassicConstants.BlockPerEra); - return (decimal) Math.Pow((double) EthereumClassicConstants.BasePercent, era) * EthereumClassicConstants.BaseRewardInitial; - } - - case ParityChainType.Expanse: - return EthereumConstants.ExpanseBlockReward; - - case ParityChainType.Ellaism: - return EthereumConstants.EllaismBlockReward; - - case ParityChainType.Ropsten: - return EthereumConstants.ByzantiumBlockReward; - - case ParityChainType.CallistoTestnet: - case ParityChainType.Callisto: - return CallistoConstants.BaseRewardInitial * (1.0m - CallistoConstants.TreasuryPercent); - - default: - throw new Exception("Unable to determine block reward: Unsupported chain type"); - } - } - - private async Task GetTxRewardAsync(DaemonResponses.Block blockInfo) - { - // fetch all tx receipts in a single RPC batch request - var batch = blockInfo.Transactions.Select(tx => new DaemonCmd(EC.GetTxReceipt, new[] { tx.Hash })) - .ToArray(); - - var results = await daemon.ExecuteBatchAnyAsync(logger, batch); - - if(results.Any(x => x.Error != null)) - throw new Exception($"Error fetching tx receipts: {string.Join(", ", results.Where(x => x.Error != null).Select(y => y.Error.Message))}"); - - // create lookup table - var gasUsed = results.Select(x => x.Response.ToObject()) - .ToDictionary(x => x.TransactionHash, x => x.GasUsed); - - // accumulate - var result = blockInfo.Transactions.Sum(x => (ulong) gasUsed[x.Hash] * ((decimal) x.GasPrice / EthereumConstants.Wei)); - - return result; - } - - internal static decimal GetUncleReward(ParityChainType chainType, ulong uheight, ulong height) - { - var reward = GetBaseBlockReward(chainType, height); - - switch(chainType) - { - case ParityChainType.Classic: - reward *= EthereumClassicConstants.UnclePercent; - break; - - default: - // https://ethereum.stackexchange.com/a/27195/18000 - reward *= uheight + 8 - height; - reward /= 8m; - break; - } - - return reward; - } - - private async Task DetectChainAsync() - { - var commands = new[] - { - new DaemonCmd(EC.GetNetVersion), - new DaemonCmd(EC.ParityChain), - }; - - var results = await daemon.ExecuteBatchAnyAsync(logger, commands); - - if(results.Any(x => x.Error != null)) - { - if(results[1].Error != null) - isParity = false; - - var errors = results.Take(1).Where(x => x.Error != null) - .ToArray(); - - if(errors.Any()) - throw new Exception($"Chain detection failed: {string.Join(", ", errors.Select(y => y.Error.Message))}"); - } - - // convert network - var netVersion = results[0].Response.ToObject(); - var parityChain = isParity ? - results[1].Response.ToObject() : - (extraPoolConfig?.ChainTypeOverride ?? "Mainnet"); - - EthereumUtils.DetectNetworkAndChain(netVersion, parityChain, out networkType, out chainType); - } - - private async Task PayoutAsync(Balance balance) - { - // unlock account - if(extraConfig.CoinbasePassword != null) - { - var unlockResponse = await daemon.ExecuteCmdSingleAsync(logger, EC.UnlockAccount, new[] - { - poolConfig.Address, - extraConfig.CoinbasePassword, - null - }); - - if(unlockResponse.Error != null || unlockResponse.Response == null || (bool) unlockResponse.Response == false) - throw new Exception("Unable to unlock coinbase account for sending transaction"); - } - - // send transaction - logger.Info(() => $"[{LogCategory}] Sending {FormatAmount(balance.Amount)} to {balance.Address}"); - - var request = new SendTransactionRequest - { - From = poolConfig.Address, - To = balance.Address, - Value = (BigInteger) Math.Floor(balance.Amount * EthereumConstants.Wei), - }; - - var response = await daemon.ExecuteCmdSingleAsync(logger, EC.SendTx, new[] { request }); - - if(response.Error != null) - throw new Exception($"{EC.SendTx} returned error: {response.Error.Message} code {response.Error.Code}"); - - if(string.IsNullOrEmpty(response.Response) || EthereumConstants.ZeroHashPattern.IsMatch(response.Response)) - throw new Exception($"{EC.SendTx} did not return a valid transaction hash"); - - var txHash = response.Response; - logger.Info(() => $"[{LogCategory}] Payout transaction id: {txHash}"); - - // update db - await PersistPaymentsAsync(new[] { balance }, txHash); - - // done - return txHash; - } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumPool.cs b/src/Miningcore/Blockchain/Ethereum/EthereumPool.cs deleted file mode 100644 index 707e8eb185..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumPool.cs +++ /dev/null @@ -1,403 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System; -using System.Linq; -using System.Reactive; -using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; -using System.Threading; -using System.Threading.Tasks; -using Autofac; -using AutoMapper; -using Miningcore.Blockchain.Ethereum.Configuration; -using Miningcore.Configuration; -using Miningcore.Extensions; -using Miningcore.JsonRpc; -using Miningcore.Messaging; -using Miningcore.Mining; -using Miningcore.Notifications.Messages; -using Miningcore.Persistence; -using Miningcore.Persistence.Repositories; -using Miningcore.Stratum; -using Miningcore.Time; -using Miningcore.Util; -using Newtonsoft.Json; - -namespace Miningcore.Blockchain.Ethereum -{ - [CoinFamily(CoinFamily.Ethereum)] - public class EthereumPool : PoolBase - { - public EthereumPool(IComponentContext ctx, - JsonSerializerSettings serializerSettings, - IConnectionFactory cf, - IStatsRepository statsRepo, - IMapper mapper, - IMasterClock clock, - IMessageBus messageBus) : - base(ctx, serializerSettings, cf, statsRepo, mapper, clock, messageBus) - { - } - - private object currentJobParams; - private EthereumJobManager manager; - - private async Task OnSubscribeAsync(StratumClient client, Timestamped tsRequest) - { - var request = tsRequest.Value; - var context = client.ContextAs(); - - if(request.Id == null) - throw new StratumException(StratumError.Other, "missing request id"); - - var requestParams = request.ParamsAs(); - - if(requestParams == null || requestParams.Length < 2 || requestParams.Any(string.IsNullOrEmpty)) - throw new StratumException(StratumError.MinusOne, "invalid request"); - - manager.PrepareWorker(client); - - var data = new object[] - { - new object[] - { - EthereumStratumMethods.MiningNotify, - client.ConnectionId, - EthereumConstants.EthereumStratumVersion - }, - context.ExtraNonce1 - } - .ToArray(); - - await client.RespondAsync(data, request.Id); - - // setup worker context - context.IsSubscribed = true; - context.UserAgent = requestParams[0].Trim(); - } - - private async Task OnAuthorizeAsync(StratumClient client, Timestamped tsRequest) - { - var request = tsRequest.Value; - var context = client.ContextAs(); - - if(request.Id == null) - throw new StratumException(StratumError.MinusOne, "missing request id"); - - var requestParams = request.ParamsAs(); - var workerValue = requestParams?.Length > 0 ? requestParams[0] : null; - var password = requestParams?.Length > 1 ? requestParams[1] : null; - var passParts = password?.Split(PasswordControlVarsSeparator); - - // extract worker/miner - var workerParts = workerValue?.Split('.'); - var minerName = workerParts?.Length > 0 ? workerParts[0].Trim() : null; - var workerName = workerParts?.Length > 1 ? workerParts[1].Trim() : null; - - // assumes that workerName is an address - context.IsAuthorized = !string.IsNullOrEmpty(minerName) && manager.ValidateAddress(minerName); - context.Miner = minerName; - context.Worker = workerName; - - // respond - await client.RespondAsync(context.IsAuthorized, request.Id); - - // extract control vars from password - var staticDiff = GetStaticDiffFromPassparts(passParts); - if(staticDiff.HasValue && - (context.VarDiff != null && staticDiff.Value >= context.VarDiff.Config.MinDiff || - context.VarDiff == null && staticDiff.Value > context.Difficulty)) - { - context.VarDiff = null; // disable vardiff - context.SetDifficulty(staticDiff.Value); - - logger.Info(() => $"[{client.ConnectionId}] Setting static difficulty of {staticDiff.Value}"); - } - - await EnsureInitialWorkSent(client); - - // log association - logger.Info(() => $"[{client.ConnectionId}] Authorized worker {workerValue}"); - } - - private async Task OnSubmitAsync(StratumClient client, Timestamped tsRequest, CancellationToken ct) - { - var request = tsRequest.Value; - var context = client.ContextAs(); - - try - { - if(request.Id == null) - throw new StratumException(StratumError.MinusOne, "missing request id"); - - // check age of submission (aged submissions are usually caused by high server load) - var requestAge = clock.Now - tsRequest.Timestamp.UtcDateTime; - - if(requestAge > maxShareAge) - { - logger.Warn(() => $"[{client.ConnectionId}] Dropping stale share submission request (server overloaded?)"); - return; - } - - // validate worker - if(!context.IsAuthorized) - throw new StratumException(StratumError.UnauthorizedWorker, "unauthorized worker"); - else if(!context.IsSubscribed) - throw new StratumException(StratumError.NotSubscribed, "not subscribed"); - - // check request - var submitRequest = request.ParamsAs(); - - if(submitRequest.Length != 3 || - submitRequest.Any(string.IsNullOrEmpty)) - throw new StratumException(StratumError.MinusOne, "malformed PoW result"); - - // recognize activity - context.LastActivity = clock.Now; - - var poolEndpoint = poolConfig.Ports[client.PoolEndpoint.Port]; - - var share = await manager.SubmitShareAsync(client, submitRequest, ct); - - await client.RespondAsync(true, request.Id); - - // publish - messageBus.SendMessage(new ClientShare(client, share)); - - // telemetry - PublishTelemetry(TelemetryCategory.Share, clock.Now - tsRequest.Timestamp.UtcDateTime, true); - - logger.Info(() => $"[{client.ConnectionId}] Share accepted: D={Math.Round(share.Difficulty / EthereumConstants.Pow2x32, 3)}"); - await EnsureInitialWorkSent(client); - - // update pool stats - if(share.IsBlockCandidate) - poolStats.LastPoolBlockTime = clock.Now; - - // update client stats - context.Stats.ValidShares++; - await UpdateVarDiffAsync(client); - } - - catch(StratumException ex) - { - // telemetry - PublishTelemetry(TelemetryCategory.Share, clock.Now - tsRequest.Timestamp.UtcDateTime, false); - - // update client stats - context.Stats.InvalidShares++; - logger.Info(() => $"[{client.ConnectionId}] Share rejected: {ex.Message}"); - - // banning - ConsiderBan(client, context, poolConfig.Banning); - - throw; - } - } - - private async Task EnsureInitialWorkSent(StratumClient client) - { - var context = client.ContextAs(); - var sendInitialWork = false; - - lock(context) - { - if(context.IsSubscribed && context.IsAuthorized && !context.IsInitialWorkSent) - { - context.IsInitialWorkSent = true; - sendInitialWork = true; - } - } - - if(sendInitialWork) - { - // send intial update - await client.NotifyAsync(EthereumStratumMethods.SetDifficulty, new object[] { context.Difficulty }); - await client.NotifyAsync(EthereumStratumMethods.MiningNotify, currentJobParams); - } - } - - protected virtual Task OnNewJobAsync(object jobParams) - { - currentJobParams = jobParams; - - logger.Info(() => $"Broadcasting job"); - - var tasks = ForEachClient(async client => - { - if(!client.IsAlive) - return; - - var context = client.ContextAs(); - - if(context.IsSubscribed && context.IsAuthorized && context.IsInitialWorkSent) - { - // check alive - var lastActivityAgo = clock.Now - context.LastActivity; - - if(poolConfig.ClientConnectionTimeout > 0 && - lastActivityAgo.TotalSeconds > poolConfig.ClientConnectionTimeout) - { - logger.Info(() => $"[{client.ConnectionId}] Booting zombie-worker (idle-timeout exceeded)"); - DisconnectClient(client); - return; - } - - // varDiff: if the client has a pending difficulty change, apply it now - if(context.ApplyPendingDifficulty()) - await client.NotifyAsync(EthereumStratumMethods.SetDifficulty, new object[] { context.Difficulty }); - - // send job - await client.NotifyAsync(EthereumStratumMethods.MiningNotify, currentJobParams); - } - }); - - return Task.WhenAll(tasks); - } - - #region Overrides - - protected override async Task SetupJobManager(CancellationToken ct) - { - manager = ctx.Resolve(); - manager.Configure(poolConfig, clusterConfig); - - await manager.StartAsync(ct); - - if(poolConfig.EnableInternalStratum == true) - { - disposables.Add(manager.Jobs - .Select(job => Observable.FromAsync(async () => - { - try - { - await OnNewJobAsync(job); - } - - catch(Exception ex) - { - logger.Debug(() => $"{nameof(OnNewJobAsync)}: {ex.Message}"); - } - })) - .Concat() - .Subscribe(_ => { }, ex => - { - logger.Debug(ex, nameof(OnNewJobAsync)); - })); - - // we need work before opening the gates - await manager.Jobs.Take(1).ToTask(ct); - } - - else - { - // keep updating NetworkStats - disposables.Add(manager.Jobs.Subscribe()); - } - } - - protected override async Task InitStatsAsync() - { - await base.InitStatsAsync(); - - blockchainStats = manager.BlockchainStats; - } - - protected override WorkerContextBase CreateClientContext() - { - return new EthereumWorkerContext(); - } - - protected override async Task OnRequestAsync(StratumClient client, - Timestamped tsRequest, CancellationToken ct) - { - var request = tsRequest.Value; - - try - { - switch(request.Method) - { - case EthereumStratumMethods.Subscribe: - await OnSubscribeAsync(client, tsRequest); - break; - - case EthereumStratumMethods.Authorize: - await OnAuthorizeAsync(client, tsRequest); - break; - - case EthereumStratumMethods.SubmitShare: - await OnSubmitAsync(client, tsRequest, ct); - break; - - case EthereumStratumMethods.ExtraNonceSubscribe: - await client.RespondErrorAsync(StratumError.Other, "not supported", request.Id, false); - break; - - default: - logger.Debug(() => $"[{client.ConnectionId}] Unsupported RPC request: {JsonConvert.SerializeObject(request, serializerSettings)}"); - - await client.RespondErrorAsync(StratumError.Other, $"Unsupported request {request.Method}", request.Id); - break; - } - } - - catch(StratumException ex) - { - await client.RespondErrorAsync(ex.Code, ex.Message, request.Id, false); - } - } - - public override double HashrateFromShares(double shares, double interval) - { - var result = shares / interval; - return result; - } - - protected override async Task OnVarDiffUpdateAsync(StratumClient client, double newDiff) - { - await base.OnVarDiffUpdateAsync(client, newDiff); - - // apply immediately and notify client - var context = client.ContextAs(); - - if(context.HasPendingDifficulty) - { - context.ApplyPendingDifficulty(); - - // send job - await client.NotifyAsync(EthereumStratumMethods.SetDifficulty, new object[] { context.Difficulty }); - await client.NotifyAsync(EthereumStratumMethods.MiningNotify, currentJobParams); - } - } - - public override void Configure(PoolConfig poolConfig, ClusterConfig clusterConfig) - { - base.Configure(poolConfig, clusterConfig); - - // validate mandatory extra config - var extraConfig = poolConfig.PaymentProcessing?.Extra?.SafeExtensionDataAs(); - if(clusterConfig.PaymentProcessing?.Enabled == true && extraConfig?.CoinbasePassword == null) - logger.ThrowLogPoolStartupException("\"paymentProcessing.coinbasePassword\" pool-configuration property missing or empty (required for unlocking wallet during payment processing)"); - } - - #endregion // Overrides - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumStratumMethods.cs b/src/Miningcore/Blockchain/Ethereum/EthereumStratumMethods.cs deleted file mode 100644 index bbf051a2ce..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumStratumMethods.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumStratumMethods - { - /// - /// Used to subscribe to work from a server, required before all other communication. - /// - public const string Subscribe = "mining.subscribe"; - - /// - /// Used to authorize a worker, required before any shares can be submitted. - /// - public const string Authorize = "mining.authorize"; - - /// - /// Basically the idea is that miner remember the last difficulty given by the previous mining session and it sends mining.suggest_difficulty(difficulty) on the beginning of the next session (it may be sent before mining.subscribe or mining.resume, but it should not be a requirement) - /// - public const string SuggestDifficulty = "mining.suggest_difficulty"; - - /// - /// Used to push new work to the miner. Previous work should be aborted if Clean Jobs = true! - /// - public const string MiningNotify = "mining.notify"; - - /// - /// Used to submit shares - /// - public const string SubmitShare = "mining.submit"; - - /// - /// Used to signal the miner to stop submitting shares under the new difficulty. - /// - public const string SetDifficulty = "mining.set_difficulty"; - - /// - /// Used to subscribe to work from a server, required before all other communication. - /// - public const string ExtraNonceSubscribe = "mining.extranonce.subscribe"; - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/EthereumUtils.cs b/src/Miningcore/Blockchain/Ethereum/EthereumUtils.cs deleted file mode 100644 index b97af4bc7b..0000000000 --- a/src/Miningcore/Blockchain/Ethereum/EthereumUtils.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; - -namespace Miningcore.Blockchain.Ethereum -{ - public class EthereumUtils - { - public static void DetectNetworkAndChain(string netVersionResponse, string parityChainResponse, - out EthereumNetworkType networkType, out ParityChainType chainType) - { - // convert network - if(int.TryParse(netVersionResponse, out var netWorkTypeInt)) - { - networkType = (EthereumNetworkType) netWorkTypeInt; - - if(!Enum.IsDefined(typeof(EthereumNetworkType), networkType)) - networkType = EthereumNetworkType.Unknown; - } - - else - networkType = EthereumNetworkType.Unknown; - - // convert chain - if(!Enum.TryParse(parityChainResponse, true, out chainType)) - { - if(parityChainResponse.ToLower() == "ethereum classic") - chainType = ParityChainType.Classic; - else - chainType = ParityChainType.Unknown; - } - - if(chainType == ParityChainType.Foundation) - chainType = ParityChainType.Mainnet; - } - } -} diff --git a/src/Miningcore/Blockchain/ExtraNonceProviderBase.cs b/src/Miningcore/Blockchain/ExtraNonceProviderBase.cs index 44694686b1..c1f7770d15 100644 --- a/src/Miningcore/Blockchain/ExtraNonceProviderBase.cs +++ b/src/Miningcore/Blockchain/ExtraNonceProviderBase.cs @@ -44,7 +44,7 @@ public ExtraNonceProviderBase(int extranonceBytes) counter = Math.Abs(instanceId & mask); } - private readonly object counterLock = new object(); + private readonly object counterLock = new(); protected long counter; protected readonly int extranonceBytes; protected readonly long nonceMax; diff --git a/src/Miningcore/Blockchain/JobManagerBase.cs b/src/Miningcore/Blockchain/JobManagerBase.cs index 169930f53c..c75385b7b1 100644 --- a/src/Miningcore/Blockchain/JobManagerBase.cs +++ b/src/Miningcore/Blockchain/JobManagerBase.cs @@ -52,11 +52,11 @@ protected JobManagerBase(IComponentContext ctx, IMessageBus messageBus) protected TJob currentJob; private int jobId; - protected object jobLock = new object(); + protected object jobLock = new(); protected ILogger logger; protected PoolConfig poolConfig; protected bool hasInitialBlockTemplate = false; - protected Subject blockFoundSubject = new Subject(); + protected Subject blockFoundSubject = new(); protected abstract void ConfigureDaemons(); @@ -96,9 +96,7 @@ protected IObservable BtStreamSubscribe(ZmqPubSubEndpointConfig config) .Where(x => x.Topic == config.Topic) .DoSafe(x => messageBus.SendMessage(new TelemetryEvent( clusterConfig.ClusterName, poolConfig.Id, TelemetryCategory.BtStream, x.Received - x.Sent)), logger) - .Select(x => x.Payload) - .Publish() - .RefCount(); + .Select(x => x.Payload); } protected virtual void OnBlockFound() diff --git a/src/Miningcore/Configuration/ClusterConfig.cs b/src/Miningcore/Configuration/ClusterConfig.cs index 2ee4d09972..c0933b8cc9 100644 --- a/src/Miningcore/Configuration/ClusterConfig.cs +++ b/src/Miningcore/Configuration/ClusterConfig.cs @@ -108,7 +108,7 @@ public abstract partial class CoinTemplate /// Coin Family associciations /// [JsonIgnore] - public static readonly Dictionary Families = new Dictionary + public static readonly Dictionary Families = new() { {CoinFamily.Bitcoin, typeof(BitcoinTemplate)}, {CoinFamily.Equihash, typeof(EquihashCoinTemplate)}, @@ -154,7 +154,7 @@ public partial class BitcoinNetworkParams public uint CoinbaseTxVersion { get; set; } /// - /// Default transaction comment for coins that REQUIRE tx comments + /// Default transaction comment for coins that REQUIRE tx comments /// public string CoinbaseTxComment { get; set; } @@ -168,6 +168,15 @@ public partial class BitcoinNetworkParams [DefaultValue(1.0d)] public double ShareMultiplier { get; set; } = 1.0d; + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool CoinbaseIgnoreAuxFlags { get; set; } + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IsPseudoPoS { get; set; } + + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public JToken BlockTemplateRpcExtraParams { get; set; } + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public Dictionary Networks { get; set; } } @@ -258,17 +267,8 @@ public enum CryptonoteSubfamily public enum CryptonightHashType { - [EnumMember(Value = "cryptonight")] - Normal = 1, - - [EnumMember(Value = "cryptonight-lite")] - Lite, - - [EnumMember(Value = "cryptonight-heavy")] - Heavy, - - [EnumMember(Value = "cryptonight-pico")] - Pico + [EnumMember(Value = "randomx")] + RandomX, } public partial class CryptonoteCoinTemplate : CoinTemplate @@ -308,12 +308,24 @@ public partial class CryptonoteCoinTemplate : CoinTemplate /// public ulong AddressPrefixTestnet { get; set; } + /// + /// Prefix of a valid stagenet-address + /// See: namespace config -> CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h + /// + public ulong AddressPrefixStagenet { get; set; } + /// /// Prefix of a valid integrated address /// See: namespace testnet -> CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h /// public ulong AddressPrefixIntegrated { get; set; } + /// + /// Prefix of a valid integrated stagenet-address + /// See: namespace testnet -> CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h + /// + public ulong AddressPrefixIntegratedStagenet { get; set; } + /// /// Prefix of a valid integrated testnet-address /// See: namespace testnet -> CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX in src/cryptonote_config.h @@ -386,11 +398,6 @@ public class DaemonEndpointConfig : AuthenticatedNetworkEndpointConfig /// public bool Http2 { get; set; } - /// - /// Set if the endpoint requires HTTP Digest Authentication (Cryptonote coins) - /// - public bool DigestAuth { get; set; } - /// /// Optional endpoint category /// @@ -678,7 +685,7 @@ public partial class PoolConfig public PoolShareBasedBanningConfig Banning { get; set; } public RewardRecipient[] RewardRecipients { get; set; } public string Address { get; set; } - public string PubKey { get; set; } // POS coins only + public string PubKey { get; set; } // POS coins only public int ClientConnectionTimeout { get; set; } public int JobRebroadcastTimeout { get; set; } public int BlockRefreshInterval { get; set; } diff --git a/src/Miningcore/Configuration/ClusterConfigExtensions.cs b/src/Miningcore/Configuration/ClusterConfigExtensions.cs index 52a6800bec..61ecda0fb7 100644 --- a/src/Miningcore/Configuration/ClusterConfigExtensions.cs +++ b/src/Miningcore/Configuration/ClusterConfigExtensions.cs @@ -181,12 +181,8 @@ public override string GetAlgorithmName() { switch(Hash) { - case CryptonightHashType.Normal: - return "Cryptonight"; - case CryptonightHashType.Lite: - return "Cryptonight-Lite"; - case CryptonightHashType.Heavy: - return "Cryptonight-Heavy"; + case CryptonightHashType.RandomX: + return "RandomX"; } throw new NotSupportedException("Invalid hash type"); diff --git a/src/Miningcore/Configuration/ClusterConfigValidation.cs b/src/Miningcore/Configuration/ClusterConfigValidation.cs index df22d15487..e53cb1c202 100644 --- a/src/Miningcore/Configuration/ClusterConfigValidation.cs +++ b/src/Miningcore/Configuration/ClusterConfigValidation.cs @@ -22,7 +22,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using FluentValidation; using System.Linq; using System.Security.Cryptography.X509Certificates; -using FluentValidation.Attributes; namespace Miningcore.Configuration { @@ -276,7 +275,6 @@ public partial class ClusterLoggingConfig { } - [Validator(typeof(VarDiffConfigValidator))] public partial class VarDiffConfig { } @@ -297,42 +295,34 @@ public partial class PersistenceConfig { } - [Validator(typeof(NetworkEndpointConfigValidator))] public partial class NetworkEndpointConfig { } - [Validator(typeof(AuthenticatedNetworkEndpointConfigValidator))] public partial class AuthenticatedNetworkEndpointConfig { } - [Validator(typeof(EmailSenderConfigValidator))] public partial class EmailSenderConfig { } - [Validator(typeof(AdminNotificationsValidator))] public partial class AdminNotifications { } - [Validator(typeof(NotificationsConfigValidator))] public partial class NotificationsConfig { } - [Validator(typeof(ApiConfigValidator))] public partial class ApiConfig { } - [Validator(typeof(PoolConfigValidator))] public partial class PoolConfig { } - [Validator(typeof(ClusterConfigValidator))] public partial class ClusterConfig { public void Validate() diff --git a/src/Miningcore/Contracts/Contract.cs b/src/Miningcore/Contracts/Contract.cs index e2797c73ea..128c2609e5 100644 --- a/src/Miningcore/Contracts/Contract.cs +++ b/src/Miningcore/Contracts/Contract.cs @@ -49,7 +49,7 @@ public static void RequiresNonNull(object parameter, string paramName) #region Exception Constructors - private static readonly ConcurrentDictionary constructors = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary constructors = new(); private delegate Exception ConstructorDelegate(object[] parameters); diff --git a/src/Miningcore/Crypto/HashAlgorithmFactory.cs b/src/Miningcore/Crypto/HashAlgorithmFactory.cs index bf7354ced2..eaa6124d88 100644 --- a/src/Miningcore/Crypto/HashAlgorithmFactory.cs +++ b/src/Miningcore/Crypto/HashAlgorithmFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; @@ -10,7 +10,7 @@ namespace Miningcore.Crypto { public static class HashAlgorithmFactory { - private static readonly ConcurrentDictionary cache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary cache = new(); public static IHashAlgorithm GetHash(IComponentContext ctx, JObject definition) { diff --git a/src/Miningcore/Crypto/Hashing/Algorithms/Kezzak.cs b/src/Miningcore/Crypto/Hashing/Algorithms/Kezzak.cs index 91be8c5d62..94dc433974 100644 --- a/src/Miningcore/Crypto/Hashing/Algorithms/Kezzak.cs +++ b/src/Miningcore/Crypto/Hashing/Algorithms/Kezzak.cs @@ -43,7 +43,7 @@ public void Digest(ReadOnlySpan data, Span result, params object[] e if(nTimeHex.Length > 0) { - var dest = dataEx.Slice(data.Length); + var dest = dataEx[data.Length..]; nTimeHex.CopyTo(dest); } diff --git a/src/Miningcore/Crypto/Hashing/Algorithms/OdoCrypt.cs b/src/Miningcore/Crypto/Hashing/Algorithms/OdoCrypt.cs deleted file mode 100644 index 9d7d770564..0000000000 --- a/src/Miningcore/Crypto/Hashing/Algorithms/OdoCrypt.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System; -using System.Runtime.CompilerServices; -using Miningcore.Contracts; -using Miningcore.Extensions; -using Miningcore.Native; -using static Miningcore.Configuration.BitcoinTemplate; - -namespace Miningcore.Crypto.Hashing.Algorithms -{ - public class OdoCryptConfig - { - public uint OdoCryptShapeChangeInterval { get; set; } - }; - - public unsafe class OdoCrypt : IHashAlgorithm - { - private static ConditionalWeakTable configs = new ConditionalWeakTable(); - - public void Digest(ReadOnlySpan data, Span result, params object[] extra) - { - Contract.Requires(extra.Length >= 4, $"{nameof(extra)} four extra parameters expected"); - Contract.Requires(data.Length <= 80, $"{nameof(data)} must be less or equal 80 bytes"); - Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - - // derive key parameter - var nTime = (uint) (ulong) extra[0]; - var networkParams = (BitcoinNetworkParams) extra[3]; - var config = configs.GetValue(networkParams, (bnp) => bnp.Extra.SafeExtensionDataAs()); - var key = nTime - nTime % config.OdoCryptShapeChangeInterval; - - fixed (byte* input = data) - { - fixed (byte* output = result) - { - LibMultihash.odocrypt(input, output, (uint) data.Length, key); - } - } - } - } -} diff --git a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolPaymentProcessingConfigExtra.cs b/src/Miningcore/Crypto/Hashing/Algorithms/X22i.cs similarity index 64% rename from src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolPaymentProcessingConfigExtra.cs rename to src/Miningcore/Crypto/Hashing/Algorithms/X22i.cs index 8b375e7857..7fe76ca03c 100644 --- a/src/Miningcore/Blockchain/Ethereum/Configuration/EthereumPoolPaymentProcessingConfigExtra.cs +++ b/src/Miningcore/Crypto/Hashing/Algorithms/X22i.cs @@ -18,23 +18,25 @@ portions of the Software. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -namespace Miningcore.Blockchain.Ethereum.Configuration +using System; +using Miningcore.Contracts; +using Miningcore.Native; + +namespace Miningcore.Crypto.Hashing.Algorithms { - public class EthereumPoolPaymentProcessingConfigExtra + public unsafe class X22I : IHashAlgorithm { - /// - /// Password of the daemons wallet (needed for processing payouts) - /// - public string CoinbasePassword { get; set; } - - /// - /// True to exempt transaction fees from miner rewards - /// - public bool KeepTransactionFees { get; set; } + public void Digest(ReadOnlySpan data, Span result, params object[] extra) + { + Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - /// - /// True to exempt uncle rewards from miner rewards - /// - public bool KeepUncles { get; set; } + fixed (byte* input = data) + { + fixed (byte* output = result) + { + LibMultihash.x22i(input, output, (uint) data.Length); + } + } + } } } diff --git a/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolver.cs b/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolver.cs index 16b7ea1bf0..d2ebb3290d 100644 --- a/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolver.cs +++ b/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolver.cs @@ -42,7 +42,7 @@ public static int MaxThreads } } - protected static readonly Lazy sem = new Lazy(() => + protected static readonly Lazy sem = new(() => new Semaphore(maxThreads, maxThreads)); protected string personalization; diff --git a/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolverFactory.cs b/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolverFactory.cs index 4b75ba32d3..64b3d2cda3 100644 --- a/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolverFactory.cs +++ b/src/Miningcore/Crypto/Hashing/Equihash/EquihashSolverFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Linq; using Autofac; @@ -10,7 +10,7 @@ namespace Miningcore.Crypto.Hashing.Equihash public static class EquihashSolverFactory { private const string HashName = "equihash"; - private static readonly ConcurrentDictionary cache = new ConcurrentDictionary(); + private static readonly ConcurrentDictionary cache = new(); public static EquihashSolver GetSolver(IComponentContext ctx, JObject definition) { diff --git a/src/Miningcore/Crypto/Hashing/Ethash/Cache.cs b/src/Miningcore/Crypto/Hashing/Ethash/Cache.cs deleted file mode 100644 index 7d31c6bd7c..0000000000 --- a/src/Miningcore/Crypto/Hashing/Ethash/Cache.cs +++ /dev/null @@ -1,81 +0,0 @@ -using System; -using System.Threading.Tasks; -using Miningcore.Blockchain.Ethereum; -using Miningcore.Contracts; -using Miningcore.Extensions; -using Miningcore.Native; -using NLog; - -namespace Miningcore.Crypto.Hashing.Ethash -{ - public class Cache : IDisposable - { - public Cache(ulong epoch) - { - Epoch = epoch; - LastUsed = DateTime.Now; - } - - private IntPtr handle = IntPtr.Zero; - private bool isGenerated = false; - private readonly object genLock = new object(); - - public ulong Epoch { get; } - public DateTime LastUsed { get; set; } - - public void Dispose() - { - if(handle != IntPtr.Zero) - { - LibMultihash.ethash_light_delete(handle); - handle = IntPtr.Zero; - } - } - - public async Task GenerateAsync(ILogger logger) - { - await Task.Run(() => - { - lock(genLock) - { - if(!isGenerated) - { - var started = DateTime.Now; - logger.Debug(() => $"Generating cache for epoch {Epoch}"); - - var block = Epoch * EthereumConstants.EpochLength; - handle = LibMultihash.ethash_light_new(block); - - logger.Debug(() => $"Done generating cache for epoch {Epoch} after {DateTime.Now - started}"); - isGenerated = true; - } - } - }); - } - - public unsafe bool Compute(ILogger logger, byte[] hash, ulong nonce, out byte[] mixDigest, out byte[] result) - { - Contract.RequiresNonNull(hash, nameof(hash)); - - logger.LogInvoke(); - - mixDigest = null; - result = null; - - var value = new LibMultihash.ethash_return_value(); - - fixed (byte* input = hash) - { - LibMultihash.ethash_light_compute(handle, input, nonce, ref value); - } - - if(value.success) - { - mixDigest = value.mix_hash.value; - result = value.result.value; - } - - return value.success; - } - } -} diff --git a/src/Miningcore/Crypto/Hashing/Ethash/Dag.cs b/src/Miningcore/Crypto/Hashing/Ethash/Dag.cs deleted file mode 100644 index a519524826..0000000000 --- a/src/Miningcore/Crypto/Hashing/Ethash/Dag.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Miningcore.Blockchain.Ethereum; -using Miningcore.Contracts; -using Miningcore.Extensions; -using Miningcore.Native; -using NLog; - -namespace Miningcore.Crypto.Hashing.Ethash -{ - public class Dag : IDisposable - { - public Dag(ulong epoch) - { - Epoch = epoch; - } - - public ulong Epoch { get; set; } - - private IntPtr handle = IntPtr.Zero; - private static readonly Semaphore sem = new Semaphore(1, 1); - - public DateTime LastUsed { get; set; } - - public static unsafe string GetDefaultDagDirectory() - { - var chars = new byte[512]; - - fixed (byte* data = chars) - { - if(LibMultihash.ethash_get_default_dirname(data, chars.Length)) - { - int length; - for(length = 0; length < chars.Length; length++) - { - if(data[length] == 0) - break; - } - - return Encoding.UTF8.GetString(data, length); - } - } - - return null; - } - - public void Dispose() - { - if(handle != IntPtr.Zero) - { - LibMultihash.ethash_full_delete(handle); - handle = IntPtr.Zero; - } - } - - public async ValueTask GenerateAsync(string dagDir, ILogger logger, CancellationToken ct) - { - Contract.Requires(!string.IsNullOrEmpty(dagDir), $"{nameof(dagDir)} must not be empty"); - - if(handle == IntPtr.Zero) - { - await Task.Run(() => - { - try - { - sem.WaitOne(); - - // re-check after obtaining lock - if(handle != IntPtr.Zero) - return; - - logger.Info(() => $"Generating DAG for epoch {Epoch}"); - - var started = DateTime.Now; - var block = Epoch * EthereumConstants.EpochLength; - - // Generate a temporary cache - var light = LibMultihash.ethash_light_new(block); - - try - { - // Generate the actual DAG - handle = LibMultihash.ethash_full_new(dagDir, light, progress => - { - logger.Info(() => $"Generating DAG for epoch {Epoch}: {progress}%"); - - return !ct.IsCancellationRequested ? 0 : 1; - }); - - if(handle == IntPtr.Zero) - throw new OutOfMemoryException("ethash_full_new IO or memory error"); - - logger.Info(() => $"Done generating DAG for epoch {Epoch} after {DateTime.Now - started}"); - } - - finally - { - if(light != IntPtr.Zero) - LibMultihash.ethash_light_delete(light); - } - } - - finally - { - sem.Release(); - } - }, ct); - } - } - - public unsafe bool Compute(ILogger logger, byte[] hash, ulong nonce, out byte[] mixDigest, out byte[] result) - { - Contract.RequiresNonNull(hash, nameof(hash)); - - logger.LogInvoke(); - - mixDigest = null; - result = null; - - var value = new LibMultihash.ethash_return_value(); - - fixed (byte* input = hash) - { - LibMultihash.ethash_full_compute(handle, input, nonce, ref value); - } - - if(value.success) - { - mixDigest = value.mix_hash.value; - result = value.result.value; - } - - return value.success; - } - } -} diff --git a/src/Miningcore/Crypto/Hashing/Ethash/EthashFull.cs b/src/Miningcore/Crypto/Hashing/Ethash/EthashFull.cs deleted file mode 100644 index 4310c9b8e2..0000000000 --- a/src/Miningcore/Crypto/Hashing/Ethash/EthashFull.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Miningcore.Blockchain.Ethereum; -using Miningcore.Contracts; -using NLog; - -namespace Miningcore.Crypto.Hashing.Ethash -{ - public class EthashFull : IDisposable - { - public EthashFull(int numCaches, string dagDir) - { - Contract.Requires(!string.IsNullOrEmpty(dagDir), $"{nameof(dagDir)} must not be empty"); - - this.numCaches = numCaches; - this.dagDir = dagDir; - } - - private int numCaches; // Maximum number of caches to keep before eviction (only init, don't modify) - private readonly object cacheLock = new object(); - private readonly Dictionary caches = new Dictionary(); - private Dag future; - private readonly string dagDir; - - public void Dispose() - { - foreach(var value in caches.Values) - value.Dispose(); - } - - public async Task GetDagAsync(ulong block, ILogger logger, CancellationToken ct) - { - var epoch = block / EthereumConstants.EpochLength; - Dag result; - - lock(cacheLock) - { - if(numCaches == 0) - numCaches = 3; - - if(!caches.TryGetValue(epoch, out result)) - { - // No cached DAG, evict the oldest if the cache limit was reached - while(caches.Count >= numCaches) - { - var toEvict = caches.Values.OrderBy(x => x.LastUsed).First(); - var key = caches.First(pair => pair.Value == toEvict).Key; - var epochToEvict = toEvict.Epoch; - - logger.Info(() => $"Evicting DAG for epoch {epochToEvict} in favour of epoch {epoch}"); - toEvict.Dispose(); - caches.Remove(key); - } - - // If we have the new DAG pre-generated, use that, otherwise create a new one - if(future != null && future.Epoch == epoch) - { - logger.Debug(() => $"Using pre-generated DAG for epoch {epoch}"); - - result = future; - future = null; - } - - else - { - logger.Info(() => $"No pre-generated DAG available, creating new for epoch {epoch}"); - result = new Dag(epoch); - } - - caches[epoch] = result; - } - - // If we used up the future cache, or need a refresh, regenerate - else if(future == null || future.Epoch <= epoch) - { - logger.Info(() => $"Pre-generating DAG for epoch {epoch + 1}"); - future = new Dag(epoch + 1); - -#pragma warning disable 4014 - future.GenerateAsync(dagDir, logger, ct); -#pragma warning restore 4014 - } - - result.LastUsed = DateTime.Now; - } - - await result.GenerateAsync(dagDir, logger, ct); - return result; - } - } -} diff --git a/src/Miningcore/Crypto/MerkleTree.cs b/src/Miningcore/Crypto/MerkleTree.cs index 3527baf565..622eecb47a 100644 --- a/src/Miningcore/Crypto/MerkleTree.cs +++ b/src/Miningcore/Crypto/MerkleTree.cs @@ -96,7 +96,7 @@ private IList CalculateSteps(IEnumerable hashList) steps.Add(L[1]); if(Ll % 2 == 1) - L.Add(L[L.Count - 1]); + L.Add(L[^1]); var Ld = new List(); diff --git a/src/Miningcore/DaemonInterface/DaemonClient.cs b/src/Miningcore/DaemonInterface/DaemonClient.cs index 3655e04463..644051456f 100644 --- a/src/Miningcore/DaemonInterface/DaemonClient.cs +++ b/src/Miningcore/DaemonInterface/DaemonClient.cs @@ -73,17 +73,13 @@ public DaemonClient(JsonSerializerSettings serializerSettings, IMessageBus messa private readonly JsonSerializerSettings serializerSettings; protected DaemonEndpointConfig[] endPoints; - private Dictionary httpClients; private readonly JsonSerializer serializer; - private static readonly HttpClient defaultHttpClient = new HttpClient(new SocketsHttpHandler + private static readonly HttpClient httpClient = new(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, - SslOptions = new SslClientAuthenticationOptions - { - RemoteCertificateValidationCallback = ((sender, certificate, chain, errors) => true), - } + ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true, }); // Telemetry @@ -99,32 +95,12 @@ protected void PublishTelemetry(TelemetryCategory cat, TimeSpan elapsed, string #region API-Surface - public void Configure(DaemonEndpointConfig[] endPoints, string digestAuthRealm = null) + public void Configure(DaemonEndpointConfig[] endPoints) { Contract.RequiresNonNull(endPoints, nameof(endPoints)); Contract.Requires(endPoints.Length > 0, $"{nameof(endPoints)} must not be empty"); this.endPoints = endPoints; - - // create one HttpClient instance per endpoint that carries the associated credentials - httpClients = endPoints.ToDictionary(endpoint => endpoint, endpoint => - { - if(string.IsNullOrEmpty(endpoint.User) || !endpoint.DigestAuth) - return defaultHttpClient; - - return new HttpClient(new SocketsHttpHandler - { - AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, - - Credentials = new NetworkCredential(endpoint.User, endpoint.Password), - PreAuthenticate = true, - - SslOptions = new SslClientAuthenticationOptions - { - RemoteCertificateValidationCallback = ((sender, certificate, chain, errors) => true), - } - }); - }); } /// @@ -347,7 +323,7 @@ private async Task BuildRequestTask(ILogger logger, DaemonEndpo request.Content = new StringContent(json, Encoding.UTF8, "application/json"); // build auth header - if(!string.IsNullOrEmpty(endPoint.User) && !endPoint.DigestAuth) + if(!string.IsNullOrEmpty(endPoint.User)) { var auth = $"{endPoint.User}:{endPoint.Password}"; var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(auth)); @@ -357,10 +333,10 @@ private async Task BuildRequestTask(ILogger logger, DaemonEndpo logger.Trace(() => $"Sending RPC request to {requestUrl}: {json}"); // send request - using(var response = await httpClients[endPoint].SendAsync(request, ct)) + using(var response = await httpClient.SendAsync(request, ct)) { // read response - var responseContent = await response.Content.ReadAsStringAsync(); + var responseContent = await response.Content.ReadAsStringAsync(ct); // deserialize response using(var jreader = new JsonTextReader(new StringReader(responseContent))) @@ -405,7 +381,7 @@ private async Task[]> BuildBatchRequestTask(ILogger logg request.Content = new StringContent(json, Encoding.UTF8, "application/json"); // build auth header - if(!string.IsNullOrEmpty(endPoint.User) && !endPoint.DigestAuth) + if(!string.IsNullOrEmpty(endPoint.User)) { var auth = $"{endPoint.User}:{endPoint.Password}"; var base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(auth)); @@ -415,7 +391,7 @@ private async Task[]> BuildBatchRequestTask(ILogger logg logger.Trace(() => $"Sending RPC request to {requestUrl}: {json}"); // send request - using(var response = await httpClients[endPoint].SendAsync(request)) + using(var response = await httpClient.SendAsync(request)) { // deserialize response var jsonResponse = await response.Content.ReadAsStringAsync(); diff --git a/src/Miningcore/Extensions/ArrayExtensions.cs b/src/Miningcore/Extensions/ArrayExtensions.cs index 28fdab436e..63dff57ee9 100644 --- a/src/Miningcore/Extensions/ArrayExtensions.cs +++ b/src/Miningcore/Extensions/ArrayExtensions.cs @@ -51,7 +51,7 @@ public static class ArrayExtensions public static BigInteger ToBigInteger(this Span value) { - return new BigInteger(value, true); + return new(value, true); } public static string ToHexString(this IEnumerable byteArray) @@ -69,6 +69,44 @@ public static string ToHexString(this Span value, bool withPrefix = false) return ToHexString(value, null, null, withPrefix); } + public static string ToHexString(this ReadOnlySpan value, bool withPrefix = false) + { + return ToHexString(value, null, null, withPrefix); + } + + public static string ToHexString(this ReadOnlySpan value, int? off, int? len, bool withPrefix = false) + { + if(value == null || value.Length == 0) + return string.Empty; + + var length = len ?? value.Length; + var bufferSize = length * 2; + + if(withPrefix) + bufferSize += 2; + + Span buffer = stackalloc char[bufferSize]; + + var offset = 0; + + if(withPrefix) + { + buffer[offset++] = '0'; + buffer[offset++] = 'x'; + } + + var start = off ?? 0; + + for(var i = start; i < length; i++) + { + var hex = HexStringTable[value[i]]; + buffer[offset + i * 2 + 0] = hex[0]; + buffer[offset + i * 2 + 1] = hex[1]; + } + + return new string(buffer); + } + public static string ToHexString(this Span value, int? off, int? len, bool withPrefix = false) { if(value == null || value.Length == 0) @@ -102,6 +140,7 @@ public static string ToHexString(this Span value, int? off, int? len, bool return new string(buffer); } + public static string ToHexString(this Memory value, bool withPrefix = false) { return ToHexString(value.Span, null, null, withPrefix); diff --git a/src/Miningcore/Extensions/JsonExtensions.cs b/src/Miningcore/Extensions/JsonExtensions.cs new file mode 100644 index 0000000000..9cfce6d8be --- /dev/null +++ b/src/Miningcore/Extensions/JsonExtensions.cs @@ -0,0 +1,42 @@ +using System; +using System.Buffers; +using System.Text.Json; + +namespace Miningcore.Extensions +{ + public static class JsonExtensions + { + public static T ToObject(this JsonElement element, JsonSerializerOptions options = null) + { + var bufferWriter = new ArrayBufferWriter(); + using (var writer = new Utf8JsonWriter(bufferWriter)) + element.WriteTo(writer); + return JsonSerializer.Deserialize(bufferWriter.WrittenSpan, options); + } + + public static T ToObject(this JsonDocument document, JsonSerializerOptions options = null) + { + if (document == null) + throw new ArgumentNullException(nameof(document)); + return document.RootElement.ToObject(options); + } + + public static JsonDocument JsonDocumentFromObject(TValue value, JsonSerializerOptions options = default) + => JsonDocumentFromObject(value, typeof(TValue), options); + + public static JsonDocument JsonDocumentFromObject(object value, Type type, JsonSerializerOptions options = default) + { + var bytes = JsonSerializer.SerializeToUtf8Bytes(value, options); + return JsonDocument.Parse(bytes); + } + + public static JsonElement JsonElementFromObject(TValue value, JsonSerializerOptions options = default) + => JsonElementFromObject(value, typeof(TValue), options); + + public static JsonElement JsonElementFromObject(object value, Type type, JsonSerializerOptions options = default) + { + using var doc = JsonDocumentFromObject(value, type, options); + return doc.RootElement.Clone(); + } + } +} diff --git a/src/Miningcore/Extensions/MessageBusExtensions.cs b/src/Miningcore/Extensions/MessageBusExtensions.cs index 322486dd55..03e0b4f662 100644 --- a/src/Miningcore/Extensions/MessageBusExtensions.cs +++ b/src/Miningcore/Extensions/MessageBusExtensions.cs @@ -1,4 +1,4 @@ -using Miningcore.Blockchain; +using Miningcore.Blockchain; using Miningcore.Messaging; using Miningcore.Persistence.Model; using System.Globalization; @@ -22,6 +22,7 @@ public static void NotifyBlockFound(this IMessageBus messageBus, string poolId, PoolId = poolId, BlockHeight = block.BlockHeight, Symbol = coin.Symbol, + Name = coin.CanonicalName ?? coin.Name, Miner = block.Miner, MinerExplorerLink = minerExplorerLink, Source = block.Source, @@ -35,6 +36,7 @@ public static void NotifyBlockConfirmationProgress(this IMessageBus messageBus, PoolId = poolId, BlockHeight = block.BlockHeight, Symbol = coin.Symbol, + Name = coin.CanonicalName ?? coin.Name, Effort = block.Effort, Progress = block.ConfirmationProgress, }); @@ -68,6 +70,7 @@ public static void NotifyBlockUnlocked(this IMessageBus messageBus, string poolI BlockHeight = block.BlockHeight, BlockType = block.Type, Symbol = coin.Symbol, + Name = coin.CanonicalName ?? coin.Name, Reward = block.Reward, Status = block.Status, Effort = block.Effort, @@ -85,6 +88,7 @@ public static void NotifyChainHeight(this IMessageBus messageBus, string poolId, PoolId = poolId, BlockHeight = height, Symbol = coin.Symbol, + Name = coin.CanonicalName ?? coin.Name, }); } diff --git a/src/Miningcore/Extensions/StringExtensions.cs b/src/Miningcore/Extensions/StringExtensions.cs index ab13b17f89..8e8428b750 100644 --- a/src/Miningcore/Extensions/StringExtensions.cs +++ b/src/Miningcore/Extensions/StringExtensions.cs @@ -37,7 +37,7 @@ public static class StringExtensions public static byte[] HexToByteArray(this string str) { if(str.StartsWith("0x")) - str = str.Substring(2); + str = str[2..]; var arr = new byte[str.Length >> 1]; var count = str.Length >> 1; @@ -56,7 +56,7 @@ public static byte[] HexToByteArray(this string str) public static byte[] HexToReverseByteArray(this string str) { if(str.StartsWith("0x")) - str = str.Substring(2); + str = str[2..]; var arr = new byte[str.Length >> 1]; var count = str.Length >> 1; @@ -118,7 +118,7 @@ public static string ToStringHexWithPrefix(this int value) public static string StripHexPrefix(this string value) { if(value?.ToLower().StartsWith("0x") == true) - return value.Substring(2); + return value[2..]; return value; } @@ -128,7 +128,7 @@ public static T IntegralFromHex(this string value) var underlyingType = Nullable.GetUnderlyingType(typeof(T)); if(value.StartsWith("0x")) - value = value.Substring(2); + value = value[2..]; if(!ulong.TryParse(value, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture, out var val)) throw new FormatException(); @@ -141,7 +141,7 @@ public static string ToLowerCamelCase(this string str) if(string.IsNullOrEmpty(str)) return str; - return char.ToLowerInvariant(str[0]) + str.Substring(1); + return char.ToLowerInvariant(str[0]) + str[1..]; } public static string AsString(this ReadOnlySequence line, Encoding encoding) @@ -154,7 +154,7 @@ public static string Capitalize(this string str) if(string.IsNullOrEmpty(str)) return str; - return str.Substring(0, 1).ToUpper() + str.Substring(1); + return str[..1].ToUpper() + str[1..]; } } } diff --git a/src/Miningcore/Extensions/ZmqExtensions.cs b/src/Miningcore/Extensions/ZmqExtensions.cs index 4fb2e5e277..8f945f25f4 100644 --- a/src/Miningcore/Extensions/ZmqExtensions.cs +++ b/src/Miningcore/Extensions/ZmqExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Linq; using System.Reactive.Disposables; @@ -16,9 +16,9 @@ namespace Miningcore.Extensions public static class ZmqExtensions { private static readonly ConcurrentDictionary knownKeys = - new ConcurrentDictionary(); + new(); - private static readonly Lazy<(byte[] PubKey, byte[] SecretKey)> ownKey = new Lazy<(byte[] PubKey, byte[] SecretKey)>(() => + private static readonly Lazy<(byte[] PubKey, byte[] SecretKey)> ownKey = new(() => { if(!ZContext.Has("curve")) throw new NotSupportedException("ZMQ library does not support curve"); diff --git a/src/Miningcore/Messaging/MessageBus.cs b/src/Miningcore/Messaging/MessageBus.cs index f7d01bc1d1..b4f114f214 100644 --- a/src/Miningcore/Messaging/MessageBus.cs +++ b/src/Miningcore/Messaging/MessageBus.cs @@ -24,7 +24,7 @@ namespace Miningcore.Messaging public class MessageBus : IMessageBus { private readonly Dictionary, NotAWeakReference> messageBus = - new Dictionary, NotAWeakReference>(); + new(); private readonly IDictionary, IScheduler> schedulerMappings = new Dictionary, IScheduler>(); diff --git a/src/Miningcore/Mining/BtStreamReceiver.cs b/src/Miningcore/Mining/BtStreamReceiver.cs index 233acee752..842b57541a 100644 --- a/src/Miningcore/Mining/BtStreamReceiver.cs +++ b/src/Miningcore/Mining/BtStreamReceiver.cs @@ -3,14 +3,11 @@ using System.IO.Compression; using System.Linq; using System.Reactive.Disposables; -using System.Reactive.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; -using System.Threading.Tasks.Dataflow; using Miningcore.Blockchain.Bitcoin.Configuration; using Miningcore.Blockchain.Cryptonote.Configuration; -using Miningcore.Blockchain.Ethereum.Configuration; using Miningcore.Configuration; using Miningcore.Contracts; using Miningcore.Extensions; @@ -24,7 +21,7 @@ namespace Miningcore.Mining { /// - /// Receives external shares from relays and re-publishes for consumption + /// Receives ready made block templates from GBTRelay /// public class BtStreamReceiver { @@ -41,8 +38,8 @@ public BtStreamReceiver(IMasterClock clock, IMessageBus messageBus) private readonly IMasterClock clock; private readonly IMessageBus messageBus; private ClusterConfig clusterConfig; - private CompositeDisposable disposables = new CompositeDisposable(); - private readonly CancellationTokenSource cts = new CancellationTokenSource(); + private readonly CompositeDisposable disposables = new(); + private readonly CancellationTokenSource cts = new(); private void StartMessageReceiver(ZmqPubSubEndpointConfig[] endpoints) { @@ -178,8 +175,7 @@ public void Start(ClusterConfig clusterConfig) var endpoints = clusterConfig.Pools.Select(x => x.Extra.SafeExtensionDataAs()?.BtStream ?? - x.Extra.SafeExtensionDataAs()?.BtStream ?? - x.Extra.SafeExtensionDataAs()?.BtStream) + x.Extra.SafeExtensionDataAs()?.BtStream) .Where(x => x != null) .DistinctBy(x => $"{x.Url}:{x.SharedEncryptionKey}") .ToArray(); diff --git a/src/Miningcore/Mining/PoolBase.cs b/src/Miningcore/Mining/PoolBase.cs index ada7255652..a225b4700e 100644 --- a/src/Miningcore/Mining/PoolBase.cs +++ b/src/Miningcore/Mining/PoolBase.cs @@ -75,21 +75,21 @@ protected PoolBase(IComponentContext ctx, this.messageBus = messageBus; } - protected PoolStats poolStats = new PoolStats(); + protected PoolStats poolStats = new(); protected readonly JsonSerializerSettings serializerSettings; protected readonly IConnectionFactory cf; protected readonly IStatsRepository statsRepo; protected readonly IMapper mapper; protected readonly IMessageBus messageBus; - protected readonly CompositeDisposable disposables = new CompositeDisposable(); + protected readonly CompositeDisposable disposables = new(); protected BlockchainStats blockchainStats; protected PoolConfig poolConfig; protected static readonly TimeSpan maxShareAge = TimeSpan.FromSeconds(6); - protected static readonly Regex regexStaticDiff = new Regex(@";?d=(\d*(\.\d+)?)", RegexOptions.Compiled); + protected static readonly Regex regexStaticDiff = new(@";?d=(\d*(\.\d+)?)", RegexOptions.Compiled); protected const string PasswordControlVarsSeparator = ";"; protected readonly Dictionary varDiffManagers = - new Dictionary(); + new(); protected abstract Task SetupJobManager(CancellationToken ct); protected abstract WorkerContextBase CreateClientContext(); @@ -204,7 +204,7 @@ protected async Task UpdateVarDiffAsync(StratumClient client, bool isIdleUpdate if(newDiff != null) { - logger.Info(() => $"[{client.ConnectionId}] VarDiff update to {Math.Round(newDiff.Value, 2)}"); + logger.Info(() => $"[{client.ConnectionId}] VarDiff update to {Math.Round(newDiff.Value, 3)}"); await OnVarDiffUpdateAsync(client, newDiff.Value); } diff --git a/src/Miningcore/Mining/ShareReceiver.cs b/src/Miningcore/Mining/ShareReceiver.cs index 94966f7c75..162bb03c7f 100644 --- a/src/Miningcore/Mining/ShareReceiver.cs +++ b/src/Miningcore/Mining/ShareReceiver.cs @@ -42,12 +42,12 @@ public ShareReceiver(IMasterClock clock, IMessageBus messageBus) private readonly IMasterClock clock; private readonly IMessageBus messageBus; private ClusterConfig clusterConfig; - private CompositeDisposable disposables = new CompositeDisposable(); - private readonly ConcurrentDictionary pools = new ConcurrentDictionary(); - private readonly BufferBlock<(string Url, ZMessage Message)> queue = new BufferBlock<(string Url, ZMessage Message)>(); - private readonly CancellationTokenSource cts = new CancellationTokenSource(); + private readonly CompositeDisposable disposables = new(); + private readonly ConcurrentDictionary pools = new(); + private readonly BufferBlock<(string Url, ZMessage Message)> queue = new(); + private readonly CancellationTokenSource cts = new(); - JsonSerializer serializer = new JsonSerializer + readonly JsonSerializer serializer = new() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; diff --git a/src/Miningcore/Mining/ShareRecorder.cs b/src/Miningcore/Mining/ShareRecorder.cs index 9a111aedef..db4281ac1b 100644 --- a/src/Miningcore/Mining/ShareRecorder.cs +++ b/src/Miningcore/Mining/ShareRecorder.cs @@ -144,9 +144,9 @@ private async Task OnExecutePolicyFallbackAsync(Context context, CancellationTok try { - using(var stream = new FileStream(recoveryFilename, FileMode.Append, FileAccess.Write)) + await using(var stream = new FileStream(recoveryFilename, FileMode.Append, FileAccess.Write)) { - using(var writer = new StreamWriter(stream, new UTF8Encoding(false))) + await using(var writer = new StreamWriter(stream, new UTF8Encoding(false))) { if(stream.Length == 0) WriteRecoveryFileheader(writer); @@ -172,7 +172,7 @@ private async Task OnExecutePolicyFallbackAsync(Context context, CancellationTok } } - private static void WriteRecoveryFileheader(StreamWriter writer) + private static void WriteRecoveryFileheader(TextWriter writer) { writer.WriteLine("# The existence of this file means shares could not be committed to the database."); writer.WriteLine("# You should stop the pool cluster and run the following command:"); @@ -189,7 +189,7 @@ public async Task RecoverSharesAsync(ClusterConfig clusterConfig, string recover var failCount = 0; const int bufferSize = 100; - using(var stream = new FileStream(recoveryFilename, FileMode.Open, FileAccess.Read)) + await using(var stream = new FileStream(recoveryFilename, FileMode.Open, FileAccess.Read)) { using(var reader = new StreamReader(stream, new UTF8Encoding(false))) { diff --git a/src/Miningcore/Mining/ShareRelay.cs b/src/Miningcore/Mining/ShareRelay.cs index a52da60a60..9b68f4ede0 100644 --- a/src/Miningcore/Mining/ShareRelay.cs +++ b/src/Miningcore/Mining/ShareRelay.cs @@ -29,7 +29,7 @@ public ShareRelay(JsonSerializerSettings serializerSettings, IMessageBus message private readonly IMessageBus messageBus; private ClusterConfig clusterConfig; - private readonly BlockingCollection queue = new BlockingCollection(); + private readonly BlockingCollection queue = new(); private IDisposable queueSub; private readonly int QueueSizeWarningThreshold = 1024; private bool hasWarnedAboutBacklogSize; diff --git a/src/Miningcore/Mining/StatsRecorder.cs b/src/Miningcore/Mining/StatsRecorder.cs index 35a9e88dd2..bd3fb55c47 100644 --- a/src/Miningcore/Mining/StatsRecorder.cs +++ b/src/Miningcore/Mining/StatsRecorder.cs @@ -57,8 +57,8 @@ public StatsRecorder(IComponentContext ctx, private readonly IMessageBus messageBus; private readonly IComponentContext ctx; private readonly IShareRepository shareRepo; - private readonly CancellationTokenSource cts = new CancellationTokenSource(); - private readonly ConcurrentDictionary pools = new ConcurrentDictionary(); + private readonly CancellationTokenSource cts = new(); + private readonly ConcurrentDictionary pools = new(); private readonly TimeSpan interval = TimeSpan.FromMinutes(5); private const int HashrateCalculationWindow = 1200; // seconds private const int MinHashrateCalculationWindow = 300; // seconds @@ -155,11 +155,8 @@ private async Task UpdatePoolHashratesAsync() var poolHashrate = pool.HashrateFromShares(poolHashesAccumulated, windowActual) * HashrateBoostFactor; // update - pool.PoolStats.ConnectedMiners = byMiner.Length; pool.PoolStats.PoolHashrate = (ulong) Math.Ceiling(poolHashrate); pool.PoolStats.SharesPerSecond = (int) (poolHashesCountAccumulated / windowActual); - - messageBus.NotifyHashrateUpdated(pool.Config.Id, poolHashrate); } } @@ -170,29 +167,9 @@ private async Task UpdatePoolHashratesAsync() pool.PoolStats.PoolHashrate = 0; pool.PoolStats.SharesPerSecond = 0; - messageBus.NotifyHashrateUpdated(pool.Config.Id, 0); - logger.Info(() => $"Reset performance stats for pool {poolId}"); } - // persist - await cf.RunTx(async (con, tx) => - { - var mapped = new Persistence.Model.PoolStats - { - PoolId = poolId, - Created = start - }; - - mapper.Map(pool.PoolStats, mapped); - mapper.Map(pool.NetworkStats, mapped); - - await statsRepo.InsertPoolStatsAsync(con, tx, mapped); - }); - - if(result.Length == 0) - continue; - // retrieve most recent miner/worker hashrate sample, if non-zero var previousMinerWorkerHashrates = await cf.Run(async (con) => { @@ -210,9 +187,12 @@ string buildKey(string miner, string worker = null) var currentNonZeroMinerWorkers = new HashSet(); // calculate & update miner, worker hashrates + var workerCount = 0; + foreach(var minerHashes in byMiner) { double minerTotalHashrate = 0; + workerCount += minerHashes.Count(); await cf.RunTx(async (con, tx) => { @@ -254,33 +234,56 @@ await cf.RunTx(async (con, tx) => // identify and reset "orphaned" hashrates var orphanedHashrateForMinerWorker = previousNonZeroMinerWorkers.Except(currentNonZeroMinerWorkers).ToArray(); - await cf.RunTx(async (con, tx) => + if(orphanedHashrateForMinerWorker.Any()) { - // reset - stats.Hashrate = 0; - stats.SharesPerSecond = 0; - - foreach(var item in orphanedHashrateForMinerWorker) + await cf.RunTx(async (con, tx) => { - var parts = item.Split(":"); - var miner = parts[0]; - var worker = parts.Length > 1 ? parts[1] : null; + // reset + stats.Hashrate = 0; + stats.SharesPerSecond = 0; - stats.Miner = parts[0]; - stats.Worker = worker; + foreach(var item in orphanedHashrateForMinerWorker) + { + var parts = item.Split("."); + var miner = parts[0]; + var worker = parts.Length > 1 ? parts[1] : null; - // persist - await statsRepo.InsertMinerWorkerPerformanceStatsAsync(con, tx, stats); + stats.Miner = miner; + stats.Worker = worker; - // broadcast - messageBus.NotifyHashrateUpdated(pool.Config.Id, 0, stats.Miner, stats.Worker); + // persist + await statsRepo.InsertMinerWorkerPerformanceStatsAsync(con, tx, stats); - if(string.IsNullOrEmpty(stats.Worker)) - logger.Info(() => $"Reset performance stats for miner {stats.Miner} on pool {poolId}"); - else - logger.Info(() => $"Reset performance stats for worker {stats.Worker} of miner {stats.Miner} on pool {poolId}"); - } + // broadcast + messageBus.NotifyHashrateUpdated(pool.Config.Id, 0, stats.Miner, stats.Worker); + + if(string.IsNullOrEmpty(stats.Worker)) + logger.Info(() => $"Reset performance stats for miner {stats.Miner} on pool {poolId}"); + else + logger.Info(() => $"Reset performance stats for worker {stats.Worker} of miner {stats.Miner} on pool {poolId}"); + } + }); + } + + // persist poolstats + pool.PoolStats.ConnectedMiners = workerCount; + + await cf.RunTx(async (con, tx) => + { + var mapped = new Persistence.Model.PoolStats + { + PoolId = poolId, + Created = start + }; + + mapper.Map(pool.PoolStats, mapped); + mapper.Map(pool.NetworkStats, mapped); + + await statsRepo.InsertPoolStatsAsync(con, tx, mapped); }); + + // broadcast + messageBus.NotifyHashrateUpdated(pool.Config.Id, pool.PoolStats.PoolHashrate); } } diff --git a/src/Miningcore/Miningcore.csproj b/src/Miningcore/Miningcore.csproj index 7f46795d58..87b2314db2 100644 --- a/src/Miningcore/Miningcore.csproj +++ b/src/Miningcore/Miningcore.csproj @@ -1,129 +1,118 @@ - + + + Exe + net5.0 + Miningcore + Miningcore + true + true + - - Exe - netcoreapp2.2 - Miningcore - Miningcore - AnyCPU - true - + + true + true + true + - - true - - - - true - true - - - - true - - - - true - 7.3 - AnyCPU - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\..\libs\WebSocketManager.dll - - - ..\..\libs\WebSocketManager.Common.dll - - - ..\..\libs\ZeroMQ.dll - - - - - - PreserveNewest - - - - - - + + + + + + + + + + + + - - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + ..\..\libs\WebSocketManager.dll + + + ..\..\libs\WebSocketManager.Common.dll + + + ..\..\libs\ZeroMQ.dll + - - - - - + + PreserveNewest + - + + + + + + %(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Miningcore/Native/LibCryptonight.cs b/src/Miningcore/Native/LibCryptonight.cs deleted file mode 100644 index c1d383c05e..0000000000 --- a/src/Miningcore/Native/LibCryptonight.cs +++ /dev/null @@ -1,243 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -using System; -using System.Collections.Concurrent; -using System.Runtime.InteropServices; -using System.Threading; -using Miningcore.Contracts; -using NLog; - -namespace Miningcore.Native -{ - public static unsafe class LibCryptonight - { - #region Hashing context managment - - internal class CryptonightContextStore - { - internal CryptonightContextStore(Func allocator, string logId) - { - this.logId = logId.ToUpper(); - - // allocate context per CPU - for(var i = 0; i < contexts.BoundedCapacity; i++) - { - contexts.Add(new Lazy(() => - { - var result = allocator(); - - return result; - })); - } - } - - private readonly string logId; - - // this holds a finite number of contexts for the cryptonight hashing functions - // if no context is currently available because all are in use, the thread waits - private readonly BlockingCollection> contexts = new BlockingCollection>(Environment.ProcessorCount); - - internal Lazy Lease() - { - logger.Debug(() => $"Leasing {logId} context ({contexts.Count})"); - - return contexts.Take(); - } - - internal void Return(Lazy ctx) - { - contexts.Add(ctx); - - logger.Debug(() => $"Returned {logId} context ({contexts.Count})"); - } - } - - private static readonly CryptonightContextStore ctxs = new CryptonightContextStore(cryptonight_alloc_context, "cn"); - private static readonly CryptonightContextStore ctxsLite = new CryptonightContextStore(cryptonight_alloc_lite_context, "cn-lite"); - private static readonly CryptonightContextStore ctxsHeavy = new CryptonightContextStore(cryptonight_alloc_heavy_context, "cn-heavy"); - private static readonly CryptonightContextStore ctxsPico = new CryptonightContextStore(cryptonight_alloc_pico_context, "cn-pico"); - - #endregion // Hashing context managment - - private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_alloc_context_export", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr cryptonight_alloc_context(); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_alloc_lite_context_export", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr cryptonight_alloc_lite_context(); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_alloc_heavy_context_export", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr cryptonight_alloc_heavy_context(); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_alloc_pico_context_export", CallingConvention = CallingConvention.Cdecl)] - private static extern IntPtr cryptonight_alloc_pico_context(); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_free_context_export", CallingConvention = CallingConvention.Cdecl)] - private static extern void cryptonight_free_context(IntPtr ptr); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_export", CallingConvention = CallingConvention.Cdecl)] - private static extern int cryptonight(IntPtr ctx, byte* input, byte* output, uint inputLength, CryptonightVariant variant, ulong height); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_light_export", CallingConvention = CallingConvention.Cdecl)] - private static extern int cryptonight_light(IntPtr ctx, byte* input, byte* output, uint inputLength, CryptonightVariant variant, ulong height); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_heavy_export", CallingConvention = CallingConvention.Cdecl)] - private static extern int cryptonight_heavy(IntPtr ctx, byte* input, byte* output, uint inputLength, CryptonightVariant variant, ulong height); - - [DllImport("libcryptonight", EntryPoint = "cryptonight_pico_export", CallingConvention = CallingConvention.Cdecl)] - private static extern int cryptonight_pico(IntPtr ctx, byte* input, byte* output, uint inputLength, CryptonightVariant variant, ulong height); - - public delegate void CryptonightHash(ReadOnlySpan data, Span result, CryptonightVariant variant, ulong height); - - // see https://github.com/xmrig/xmrig/blob/master/src/common/xmrig.h - public enum CryptonightVariant - { - VARIANT_AUTO = -1, // Autodetect - VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy - VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7 - VARIANT_TUBE = 2, // Modified CryptoNight-Heavy (TUBE only) - VARIANT_XTL = 3, // Modified CryptoNight variant 1 (Stellite only) - VARIANT_MSR = 4, // Modified CryptoNight variant 1 (Masari only) - VARIANT_XHV = 5, // Modified CryptoNight-Heavy (Haven Protocol only) - VARIANT_XAO = 6, // Modified CryptoNight variant 0 (Alloy only) - VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only) - VARIANT_2 = 8, // CryptoNight variant 2 - VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite) - VARIANT_TRTL = 10, // CryptoNight Turtle (TRTL) - VARIANT_GPU = 11, // CryptoNight-GPU (Ryo) - VARIANT_WOW = 12, // CryptoNightR (Wownero) - VARIANT_4 = 13, // CryptoNightR (Monero's variant 4) - VARIANT_RWZ = 14, // CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft) - VARIANT_ZLS = 15, // CryptoNight variant 2 with 3/4 iterations (Zelerius) - VARIANT_DOUBLE = 16, // CryptoNight variant 2 with double iterations (X-CASH) - VARIANT_MAX - }; - - /// - /// Cryptonight Hash (Monero, Monero v7, v8 etc.) - /// - /// Algorithm variant - public static void Cryptonight(ReadOnlySpan data, Span result, CryptonightVariant variant, ulong height) - { - Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - - var ctx = ctxs.Lease(); - - try - { - fixed (byte* input = data) - { - fixed (byte* output = result) - { - cryptonight(ctx.Value, input, output, (uint) data.Length, variant, height); - } - } - } - - finally - { - ctxs.Return(ctx); - } - } - - /// - /// Cryptonight Lite Hash (AEON etc.) - /// - /// Algorithm variant - public static void CryptonightLight(ReadOnlySpan data, Span result, CryptonightVariant variant, ulong height) - { - Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - - var ctx = ctxsLite.Lease(); - - try - { - fixed (byte* input = data) - { - fixed (byte* output = result) - { - cryptonight_light(ctx.Value, input, output, (uint) data.Length, variant, height); - } - } - } - - finally - { - ctxsLite.Return(ctx); - } - } - - /// - /// Cryptonight Heavy Hash (TUBE etc.) - /// - /// Algorithm variant - public static void CryptonightHeavy(ReadOnlySpan data, Span result, CryptonightVariant variant, ulong height) - { - Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - - var ctx = ctxsHeavy.Lease(); - - try - { - fixed (byte* input = data) - { - fixed (byte* output = result) - { - cryptonight_heavy(ctx.Value, input, output, (uint) data.Length, variant, height); - } - } - } - - finally - { - ctxsHeavy.Return(ctx); - } - } - - /// - /// Cryptonight Pico Hash (TUBE etc.) - /// - /// Algorithm variant - public static void CryptonightPico(ReadOnlySpan data, Span result, CryptonightVariant variant, ulong height) - { - Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); - - var ctx = ctxsPico.Lease(); - - try - { - fixed (byte* input = data) - { - fixed (byte* output = result) - { - cryptonight_pico(ctx.Value, input, output, (uint) data.Length, variant, height); - } - } - } - - finally - { - ctxsPico.Return(ctx); - } - } - } -} diff --git a/src/Miningcore/Native/LibMultihash.cs b/src/Miningcore/Native/LibMultihash.cs index cc452b8c50..149ee0b7de 100644 --- a/src/Miningcore/Native/LibMultihash.cs +++ b/src/Miningcore/Native/LibMultihash.cs @@ -49,6 +49,9 @@ public static unsafe class LibMultihash [DllImport("libmultihash", EntryPoint = "x21s_export", CallingConvention = CallingConvention.Cdecl)] public static extern int x21s(byte* input, void* output, uint inputLength); + [DllImport("libmultihash", EntryPoint = "x22i_export", CallingConvention = CallingConvention.Cdecl)] + public static extern int x22i(byte* input, void* output, uint inputLength); + [DllImport("libmultihash", EntryPoint = "x25x_export", CallingConvention = CallingConvention.Cdecl)] public static extern int x25x(byte* input, void* output, uint inputLength); diff --git a/src/Miningcore/Native/LibRandomX.cs b/src/Miningcore/Native/LibRandomX.cs new file mode 100644 index 0000000000..258afad4df --- /dev/null +++ b/src/Miningcore/Native/LibRandomX.cs @@ -0,0 +1,316 @@ +/* +Copyright 2017 Coin Foundry (coinfoundry.org) +Authors: Oliver Weichhold (oliver@weichhold.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and +associated documentation files (the "Software"), to deal in the Software without restriction, +including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial +portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT +LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; +using Miningcore.Contracts; +using Miningcore.Extensions; +using MoreLinq; +using NLog; + +// ReSharper disable InconsistentNaming + +namespace Miningcore.Native +{ + public static unsafe class LibRandomX + { + #region Context managment + + private static readonly ConcurrentDictionary>> generations = new(); + private static readonly Thread gcThread; + private static readonly byte[] empty = new byte[32]; + + static LibRandomX() + { + // GC + gcThread = new Thread(() => + { + while(true) + { + Thread.Sleep(TimeSpan.FromMinutes(1)); + + var list = new List>>>(); + + foreach(var pair in generations) + { + if(DateTime.Now - pair.Value.Item1.LastAccess > TimeSpan.FromMinutes(5)) + list.Add(pair); + } + + foreach(var pair in list.OrderBy(x=> DateTime.Now - x.Value.Item1.LastAccess, OrderByDirection.Descending)) + { + // don't dispose remaining VM + if(generations.Count <= 1) + break; + + if(generations.TryRemove(pair.Key, out var item)) + { + // remove all associated VMs + var remaining = item.Item1.VmCount; + var col = item.Item2; + + while(remaining > 0) + { + var vm = col.Take(); + + logger.Info($"Disposing VM {item.Item1.VmCount - remaining} for seed hash {pair.Key}"); + vm.Dispose(); + remaining--; + } + + col.Dispose(); + } + } + } + }); + + gcThread.Start(); + } + + #endregion // Context managment + + private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); + + [Flags] + public enum randomx_flags + { + RANDOMX_FLAG_DEFAULT = 0, + RANDOMX_FLAG_LARGE_PAGES = 1, + RANDOMX_FLAG_HARD_AES = 2, + RANDOMX_FLAG_FULL_MEM = 4, + RANDOMX_FLAG_JIT = 8, + RANDOMX_FLAG_SECURE = 16, + RANDOMX_FLAG_ARGON2_SSSE3 = 32, + RANDOMX_FLAG_ARGON2_AVX2 = 64, + RANDOMX_FLAG_ARGON2 = 96 + }; + + [DllImport("librandomx", EntryPoint = "randomx_get_flags", CallingConvention = CallingConvention.Cdecl)] + private static extern randomx_flags randomx_get_flags(); + + [DllImport("librandomx", EntryPoint = "randomx_alloc_cache", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_alloc_cache(randomx_flags flags); + + [DllImport("librandomx", EntryPoint = "randomx_init_cache", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_init_cache(IntPtr cache, IntPtr key, int keysize); + + [DllImport("librandomx", EntryPoint = "randomx_release_cache", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_release_cache(IntPtr cache); + + [DllImport("librandomx", EntryPoint = "randomx_alloc_dataset", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_alloc_dataset(randomx_flags flags); + + [DllImport("librandomx", EntryPoint = "randomx_dataset_item_count", CallingConvention = CallingConvention.Cdecl)] + private static extern ulong randomx_dataset_item_count(); + + [DllImport("librandomx", EntryPoint = "randomx_init_dataset", CallingConvention = CallingConvention.Cdecl)] + private static extern void randomx_init_dataset(IntPtr dataset, IntPtr cache, ulong startItem, ulong itemCount); + + [DllImport("librandomx", EntryPoint = "randomx_get_dataset_memory", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_get_dataset_memory(IntPtr dataset); + + [DllImport("librandomx", EntryPoint = "randomx_release_dataset", CallingConvention = CallingConvention.Cdecl)] + private static extern void randomx_release_dataset(IntPtr dataset); + + [DllImport("librandomx", EntryPoint = "randomx_create_vm", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_create_vm(randomx_flags flags, IntPtr cache, IntPtr dataset); + + [DllImport("librandomx", EntryPoint = "randomx_vm_set_cache", CallingConvention = CallingConvention.Cdecl)] + private static extern void randomx_vm_set_cache(IntPtr machine, IntPtr cache); + + [DllImport("librandomx", EntryPoint = "randomx_vm_set_dataset", CallingConvention = CallingConvention.Cdecl)] + private static extern IntPtr randomx_vm_set_dataset(IntPtr machine, IntPtr dataset); + + [DllImport("librandomx", EntryPoint = "randomx_destroy_vm", CallingConvention = CallingConvention.Cdecl)] + private static extern void randomx_destroy_vm(IntPtr machine); + + [DllImport("librandomx", EntryPoint = "randomx_calculate_hash", CallingConvention = CallingConvention.Cdecl)] + private static extern void randomx_calculate_hash(IntPtr machine, byte* input, int inputSize, byte* output); + + private class GenContext + { + public DateTime LastAccess { get; set; } = DateTime.Now; + public int VmCount { get; init; } + } + + private class RxDataSet : IDisposable + { + private IntPtr dataset = IntPtr.Zero; + + public void Dispose() + { + if(dataset != IntPtr.Zero) + { + randomx_release_dataset(dataset); + dataset = IntPtr.Zero; + } + } + + public IntPtr Init(ReadOnlySpan key, randomx_flags flags, IntPtr cache) + { + dataset = randomx_alloc_dataset(flags); + + var itemCount = randomx_dataset_item_count(); + randomx_init_dataset(dataset, cache, 0, itemCount); + + return dataset; + } + } + + private class RxVm : IDisposable + { + private IntPtr cache = IntPtr.Zero; + private IntPtr vm = IntPtr.Zero; + private RxDataSet ds; + private randomx_flags flags; + + public IntPtr Handle => vm; + public randomx_flags Flags => flags; + + public void Dispose() + { + if(vm != IntPtr.Zero) + { + randomx_destroy_vm(vm); + vm = IntPtr.Zero; + } + + ds?.Dispose(); + + if(cache != IntPtr.Zero) + { + randomx_release_cache(cache); + cache = IntPtr.Zero; + } + } + + public void Init(ReadOnlySpan key, randomx_flags? flags_override = null) + { + flags = flags_override ?? randomx_get_flags(); + + cache = randomx_alloc_cache(flags); + + fixed(byte* key_ptr = key) + { + randomx_init_cache(cache, (IntPtr) key_ptr, key.Length); + } + + ds = new RxDataSet(); + var ds_ptr = ds.Init(key, flags, cache); + + vm = randomx_create_vm(flags, cache, ds_ptr); + } + + public void CalculateHash(ReadOnlySpan data, Span result) + { + fixed (byte* input = data) + { + fixed (byte* output = result) + { + randomx_calculate_hash(vm, input, data.Length, output); + } + } + } + } + + private static Tuple> CreateGeneration(byte[] key, randomx_flags? flags, int vmCount, string keyString) + { + var vms = new BlockingCollection(); + + if (vmCount == -1) + vmCount = Environment.ProcessorCount; + + var generation = new Tuple>(new GenContext + { + VmCount = vmCount + }, vms); + + void createVm(int index) + { + var start = DateTime.Now; + logger.Info(() => $"Creating VM {index + 1} for seed hash {keyString} ..."); + + var vm = new RxVm(); + vm.Init(key, flags); + + vms.Add(vm); + + logger.Info(() => $"VM {index + 1} created in {DateTime.Now - start} ({vm.Flags})"); + }; + + Parallel.For(0, vmCount, createVm); + + return generation; + } + + private static Tuple> GetGeneration(byte[] key, randomx_flags? flags, int vmCount) + { + var keyString = key.ToHexString(); + + if(!generations.TryGetValue(keyString, out var item)) + { + item = CreateGeneration(key, flags, vmCount, keyString); + + generations[keyString] = item; + } + + return item; + } + + public static void CalculateHash(byte[] key, ReadOnlySpan data, Span result, randomx_flags? flags = null, int vmCount = 1) + { + Contract.Requires(result.Length >= 32, $"{nameof(result)} must be greater or equal 32 bytes"); + + var (ctx, vms) = GetGeneration(key, flags, vmCount); + RxVm vm = null; + + try + { + // lease a VM + vm = vms.Take(); + + vm.CalculateHash(data, result); + + // update timestamp + ctx.LastAccess = DateTime.Now; + } + + catch(Exception ex) + { + logger.Error(()=> ex.Message); + + // clear result + empty.CopyTo(result); + } + + finally + { + // return VM + if(vm != null) + vms.Add(vm); + } + } + } +} diff --git a/src/Miningcore/Notifications/Messages/BlockNotification.cs b/src/Miningcore/Notifications/Messages/BlockNotification.cs index bb63a26738..a7abafee46 100644 --- a/src/Miningcore/Notifications/Messages/BlockNotification.cs +++ b/src/Miningcore/Notifications/Messages/BlockNotification.cs @@ -9,6 +9,7 @@ public abstract class BlockNotification public string PoolId { get; set; } public ulong BlockHeight { get; set; } public string Symbol { get; set; } + public string Name { get; set; } } public class BlockFoundNotification : BlockNotification diff --git a/src/Miningcore/Payments/PaymentSchemes/PPLNSPaymentScheme.cs b/src/Miningcore/Payments/PaymentSchemes/PPLNSPaymentScheme.cs index de65cc2479..4fdd04b884 100644 --- a/src/Miningcore/Payments/PaymentSchemes/PPLNSPaymentScheme.cs +++ b/src/Miningcore/Payments/PaymentSchemes/PPLNSPaymentScheme.cs @@ -157,7 +157,7 @@ private async Task LogDiscardedSharesAsync(PoolConfig poolConfig, Block block, D if(page.Length < pageSize) break; - before = page[page.Length - 1].Created; + before = page[^1].Created; } if(shares.Keys.Count > 0) @@ -242,7 +242,7 @@ private async Task LogDiscardedSharesAsync(PoolConfig poolConfig, Block block, D if(page.Length < pageSize) break; - before = page[page.Length - 1].Created; + before = page[^1].Created; } logger.Info(() => $"Balance-calculation for pool {poolConfig.Id}, block {block.BlockHeight} completed with accumulated score {accumulatedScore:0.####} ({(accumulatedScore / window) * 100:0.#}%)"); diff --git a/src/Miningcore/Payments/PayoutHandlerBase.cs b/src/Miningcore/Payments/PayoutHandlerBase.cs index 14add42dbb..b9d37ddf4b 100644 --- a/src/Miningcore/Payments/PayoutHandlerBase.cs +++ b/src/Miningcore/Payments/PayoutHandlerBase.cs @@ -140,8 +140,7 @@ await cf.RunTx(async (con, tx) => { foreach(var balance in balances) { - if(!string.IsNullOrEmpty(transactionConfirmation) && - !poolConfig.RewardRecipients.Any(x => x.Address == balance.Address)) + if(!string.IsNullOrEmpty(transactionConfirmation) && poolConfig.RewardRecipients.All(x => x.Address != balance.Address)) { // record payment var payment = new Payment diff --git a/src/Miningcore/Payments/PayoutManager.cs b/src/Miningcore/Payments/PayoutManager.cs index b0b11842bb..12d6ec2e7e 100644 --- a/src/Miningcore/Payments/PayoutManager.cs +++ b/src/Miningcore/Payments/PayoutManager.cs @@ -71,7 +71,7 @@ public PayoutManager(IComponentContext ctx, private readonly IComponentContext ctx; private readonly IShareRepository shareRepo; private readonly IMessageBus messageBus; - private readonly CancellationTokenSource cts = new CancellationTokenSource(); + private readonly CancellationTokenSource cts = new(); private TimeSpan interval; private ClusterConfig clusterConfig; private static readonly ILogger logger = LogManager.GetCurrentClassLogger(); diff --git a/src/Miningcore/Persistence/Postgres/Repositories/BlockRepository.cs b/src/Miningcore/Persistence/Postgres/Repositories/BlockRepository.cs index eb855c7957..fb143a4f69 100644 --- a/src/Miningcore/Persistence/Postgres/Repositories/BlockRepository.cs +++ b/src/Miningcore/Persistence/Postgres/Repositories/BlockRepository.cs @@ -133,5 +133,23 @@ public async Task GetBlockBeforeAsync(IDbConnection con, string poolId, B .Select(mapper.Map) .FirstOrDefault(); } + + public Task GetPoolBlockCountAsync(IDbConnection con, string poolId) + { + logger.LogInvoke(new[] { poolId }); + + const string query = "SELECT COUNT(*) FROM blocks WHERE poolid = @poolId"; + + return con.ExecuteScalarAsync(query, new { poolId }); + } + + public Task GetLastPoolBlockTimeAsync(IDbConnection con, string poolId) + { + logger.LogInvoke(new[] { poolId }); + + const string query = "SELECT created FROM blocks WHERE poolid = @poolId ORDER BY created DESC LIMIT 1"; + + return con.ExecuteScalarAsync(query, new { poolId }); + } } } diff --git a/src/Miningcore/Persistence/Postgres/Repositories/PaymentRepository.cs b/src/Miningcore/Persistence/Postgres/Repositories/PaymentRepository.cs index 43b9b8fe1f..a51578d5c0 100644 --- a/src/Miningcore/Persistence/Postgres/Repositories/PaymentRepository.cs +++ b/src/Miningcore/Persistence/Postgres/Repositories/PaymentRepository.cs @@ -94,5 +94,43 @@ public async Task PageMinerPaymentsByDayAsync(IDbConnection con, return (await con.QueryAsync(query, new { poolId, address, offset = page * pageSize, pageSize })) .ToArray(); } + + public Task GetPaymentsCountAsync(IDbConnection con, string poolId, string address = null) + { + logger.LogInvoke(new[] { poolId }); + + string query = "SELECT COUNT(*) FROM payments WHERE poolid = @poolId"; + + if(!string.IsNullOrEmpty(address)) + query += " AND address = @address "; + + + return con.ExecuteScalarAsync(query, new { poolId, address }); + } + + public Task GetMinerPaymentsByDayCountAsync(IDbConnection con, string poolId, string address) + { + logger.LogInvoke(new[] { poolId }); + + const string query = "SELECT COUNT(*) FROM (SELECT SUM(amount) AS amount, date_trunc('day', created) AS date FROM payments WHERE poolid = @poolid " + + "AND address = @address " + + "GROUP BY date " + + "ORDER BY date DESC) s"; + + return con.ExecuteScalarAsync(query, new { poolId, address }); + } + + public Task GetBalanceChangesCountAsync(IDbConnection con, string poolId, string address = null) + { + logger.LogInvoke(new[] { poolId }); + + string query = "SELECT COUNT(*) FROM balance_changes WHERE poolid = @poolId"; + + if(!string.IsNullOrEmpty(address)) + query += " AND address = @address "; + + + return con.ExecuteScalarAsync(query, new { poolId, address }); + } } } diff --git a/src/Miningcore/Persistence/Repositories/IBlockRepository.cs b/src/Miningcore/Persistence/Repositories/IBlockRepository.cs index 3dda0018a9..1a7154e1cf 100644 --- a/src/Miningcore/Persistence/Repositories/IBlockRepository.cs +++ b/src/Miningcore/Persistence/Repositories/IBlockRepository.cs @@ -35,5 +35,7 @@ public interface IBlockRepository Task PageBlocksAsync(IDbConnection con, BlockStatus[] status, int page, int pageSize); Task GetPendingBlocksForPoolAsync(IDbConnection con, string poolId); Task GetBlockBeforeAsync(IDbConnection con, string poolId, BlockStatus[] status, DateTime before); + Task GetPoolBlockCountAsync(IDbConnection con, string poolId); + Task GetLastPoolBlockTimeAsync(IDbConnection con, string poolId); } } diff --git a/src/Miningcore/Persistence/Repositories/IPaymentRepository.cs b/src/Miningcore/Persistence/Repositories/IPaymentRepository.cs index 40e7f2adf3..12348c6124 100644 --- a/src/Miningcore/Persistence/Repositories/IPaymentRepository.cs +++ b/src/Miningcore/Persistence/Repositories/IPaymentRepository.cs @@ -32,5 +32,8 @@ public interface IPaymentRepository Task PagePaymentsAsync(IDbConnection con, string poolId, string address, int page, int pageSize); Task PageBalanceChangesAsync(IDbConnection con, string poolId, string address, int page, int pageSize); Task PageMinerPaymentsByDayAsync(IDbConnection con, string poolId, string address, int page, int pageSize); + Task GetPaymentsCountAsync(IDbConnection con, string poolId, string address = null); + Task GetMinerPaymentsByDayCountAsync(IDbConnection con, string poolId, string address); + Task GetBalanceChangesCountAsync(IDbConnection con, string poolId, string address = null); } } diff --git a/src/Miningcore/Program.cs b/src/Miningcore/Program.cs index 97f460a7c1..c4c668d1be 100644 --- a/src/Miningcore/Program.cs +++ b/src/Miningcore/Program.cs @@ -19,36 +19,41 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; -using System.Reactive; -using System.Reactive.Linq; -using System.Reactive.Threading.Tasks; using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using AspNetCoreRateLimit; using Autofac; +using Autofac.Extensions.DependencyInjection; using Autofac.Features.Metadata; using AutoMapper; using FluentValidation; using McMaster.Extensions.CommandLineUtils; -using Microsoft.AspNetCore; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; using Miningcore.Api; using Miningcore.Api.Controllers; +using Miningcore.Api.Middlewares; using Miningcore.Api.Responses; using Miningcore.Configuration; using Miningcore.Crypto.Hashing.Equihash; +using Miningcore.Extensions; using Miningcore.Mining; +using Miningcore.Native; using Miningcore.Notifications; using Miningcore.Payments; using Miningcore.Persistence.Dummy; @@ -61,56 +66,29 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. using NLog; using NLog.Conditions; using NLog.Config; +using NLog.Extensions.Hosting; +using NLog.Extensions.Logging; using NLog.Layouts; using NLog.Targets; -using JsonSerializer = Newtonsoft.Json.JsonSerializer; -using Microsoft.Extensions.Logging; -using LogLevel = NLog.LogLevel; -using ILogger = NLog.ILogger; -using NLog.Extensions.Logging; using Prometheus; using WebSocketManager; -using Miningcore.Api.Middlewares; -using System.Collections.Concurrent; -using Microsoft.AspNetCore.Http; -using AspNetCoreRateLimit; +using ILogger = NLog.ILogger; +using LogLevel = Microsoft.Extensions.Logging.LogLevel; + +// ReSharper disable AssignNullToNotNullAttribute +// ReSharper disable PossibleNullReferenceException namespace Miningcore { - public class Program + public class Program : BackgroundService { - private static readonly CancellationTokenSource cts = new CancellationTokenSource(); - private static IContainer container; - private static ILogger logger; - private static CommandOption dumpConfigOption; - private static CommandOption shareRecoveryOption; - private static bool isShareRecoveryMode; - private static ShareRecorder shareRecorder; - private static ShareRelay shareRelay; - private static ShareReceiver shareReceiver; - private static PayoutManager payoutManager; - private static StatsRecorder statsRecorder; - private static ClusterConfig clusterConfig; - private static IWebHost webHost; - private static NotificationService notificationService; - private static MetricsPublisher metricsPublisher; - private static BtStreamReceiver btStreamReceiver; - private static readonly ConcurrentDictionary pools = new ConcurrentDictionary(); - - private static AdminGcStats gcStats = new AdminGcStats(); - private static readonly Regex regexJsonTypeConversionError = - new Regex("\"([^\"]+)\"[^\']+\'([^\']+)\'.+\\s(\\d+),.+\\s(\\d+)", RegexOptions.Compiled); - private static readonly IPAddress IPv4LoopBackOnIPv6 = IPAddress.Parse("::ffff:127.0.0.1"); - - public static void Main(string[] args) + public static async Task Main(string[] args) { try { AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnhandledException; - AppDomain.CurrentDomain.ProcessExit += OnProcessExit; - Console.CancelKeyPress += OnCancelKeyPress; - if(!HandleCommandLineOptions(args, out var configFile)) + if(!ParseCommandLine(args, out var configFile)) return; isShareRecoveryMode = shareRecoveryOption.HasValue(); @@ -125,17 +103,106 @@ public static void Main(string[] args) } ValidateConfig(); - Bootstrap(); + ConfigureLogging(); LogRuntimeInfo(); + ConfigureMisc(); + ValidateRuntimeEnvironment(); - if(!isShareRecoveryMode) + var hostBuilder = new HostBuilder(); + + hostBuilder + .UseServiceProviderFactory(new AutofacServiceProviderFactory()) + .ConfigureContainer((Action) ConfigureAutofac) + .UseNLog() + .ConfigureLogging(logging => + { + logging.ClearProviders(); + logging.AddNLog(); + logging.SetMinimumLevel(LogLevel.Trace); + }) + .ConfigureServices((ctx, services) => + { + services.AddHostedService(); + }); + + if(clusterConfig.Api == null || clusterConfig.Api.Enabled) { - if(!cts.IsCancellationRequested) - Start().Wait(cts.Token); + var address = clusterConfig.Api?.ListenAddress != null + ? (clusterConfig.Api.ListenAddress != "*" ? IPAddress.Parse(clusterConfig.Api.ListenAddress) : IPAddress.Any) + : IPAddress.Parse("127.0.0.1"); + + var port = clusterConfig.Api?.Port ?? 4000; + var enableApiRateLimiting = clusterConfig.Api?.RateLimiting?.Disabled != true; + + hostBuilder.ConfigureWebHost(builder => + { + builder.ConfigureServices(services => + { + // rate limiting + if(enableApiRateLimiting) + { + services.Configure(ConfigureIpRateLimitOptions); + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + } + + services.AddSingleton(); + + // Controllers + services.AddSingleton(); + services.AddSingleton(); + + // MVC + services.AddSingleton(); + + services.AddMvc(options => { options.EnableEndpointRouting = false; }) + .SetCompatibilityVersion(CompatibilityVersion.Latest) + .AddControllersAsServices() + .AddJsonOptions(options => { options.JsonSerializerOptions.WriteIndented = true; }); + + // Gzip Compression + services.AddResponseCompression(); + + // Cors + services.AddCors(); + + // WebSockets + services.AddWebSocketManager(); + }) + .UseKestrel(options => + { + options.Listen(address, port, listenOptions => + { + if(clusterConfig.Api.SSLConfig?.Enabled == true) + listenOptions.UseHttps(clusterConfig.Api.SSLConfig.SSLPath, clusterConfig.Api.SSLConfig.SSLPassword); + }); + }) + .Configure(app => + { + if(enableApiRateLimiting) + app.UseIpRateLimiting(); + + app.UseMiddleware(); + + UseIpWhiteList(app, true, new[] { "/api/admin" }, clusterConfig.Api?.AdminIpWhitelist); + UseIpWhiteList(app, true, new[] { "/metrics" }, clusterConfig.Api?.MetricsIpWhitelist); + + app.UseResponseCompression(); + app.UseCors(corsPolicyBuilder => corsPolicyBuilder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); + app.UseWebSockets(); + app.MapWebSocketManager("/notifications", app.ApplicationServices.GetService()); + app.UseMetricServer(); + app.UseMvc(); + + }); + + logger.Info(() => $"Prometheus Metrics {address}:{port}/metrics"); + logger.Info(() => $"WebSocket notifications streaming {address}:{port}/notifications"); + }); } - else - RecoverSharesAsync(shareRecoveryOption.Value()).Wait(); + await hostBuilder.RunConsoleAsync(); } catch(PoolStartupAbortException ex) @@ -158,7 +225,7 @@ public static void Main(string[] args) catch(AggregateException ex) { - if(!(ex.InnerExceptions.First() is PoolStartupAbortException)) + if(ex.InnerExceptions.First() is not PoolStartupAbortException) Console.WriteLine(ex); Console.WriteLine("Cluster cannot start. Good Bye!"); @@ -175,10 +242,146 @@ public static void Main(string[] args) Console.WriteLine("Cluster cannot start. Good Bye!"); } + } + + private readonly IComponentContext container; + private static ILogger logger; + private static CommandOption dumpConfigOption; + private static CommandOption shareRecoveryOption; + private static bool isShareRecoveryMode; + private ShareRecorder shareRecorder; + private ShareRelay shareRelay; + private ShareReceiver shareReceiver; + private PayoutManager payoutManager; + private StatsRecorder statsRecorder; + private static ClusterConfig clusterConfig; + private NotificationService notificationService; + private MetricsPublisher metricsPublisher; + private BtStreamReceiver btStreamReceiver; + private static readonly ConcurrentDictionary pools = new(); + + private static readonly AdminGcStats gcStats = new(); + private static readonly Regex regexJsonTypeConversionError = + new("\"([^\"]+)\"[^\']+\'([^\']+)\'.+\\s(\\d+),.+\\s(\\d+)", RegexOptions.Compiled); + + public Program(IComponentContext container) + { + this.container = container; + } + + private static void ConfigureAutofac(ContainerBuilder builder) + { + builder.RegisterAssemblyModules(typeof(AutofacModule).GetTypeInfo().Assembly); + builder.RegisterInstance(clusterConfig); + builder.RegisterInstance(pools); + builder.RegisterInstance(gcStats); + + // AutoMapper + var amConf = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperProfile()); }); + builder.Register((ctx, parms) => amConf.CreateMapper()); + + ConfigurePersistence(builder); + } + + protected override async Task ExecuteAsync(CancellationToken ct) + { + if(!isShareRecoveryMode) + { + MonitorGc(); + + var coinTemplates = LoadCoinTemplates(); + logger.Info($"{coinTemplates.Keys.Count} coins loaded from {string.Join(", ", clusterConfig.CoinTemplates)}"); + + // Populate pool configs with corresponding template + foreach(var poolConfig in clusterConfig.Pools.Where(x => x.Enabled)) + { + // Lookup coin definition + if(!coinTemplates.TryGetValue(poolConfig.Coin, out var template)) + logger.ThrowLogPoolStartupException($"Pool {poolConfig.Id} references undefined coin '{poolConfig.Coin}'"); + + poolConfig.Template = template; + } + + // Notifications + notificationService = container.Resolve(); + + // start btStream receiver + btStreamReceiver = container.Resolve(); + btStreamReceiver.Start(clusterConfig); + + if(clusterConfig.ShareRelay == null) + { + // start share recorder + shareRecorder = container.Resolve(); + shareRecorder.Start(clusterConfig); + + // start share receiver (for external shares) + shareReceiver = container.Resolve(); + shareReceiver.Start(clusterConfig); + } + + else + { + // start share relay + shareRelay = container.Resolve(); + shareRelay.Start(clusterConfig); + } + + // start API + if(clusterConfig.Api == null || clusterConfig.Api.Enabled) + { + metricsPublisher = container.Resolve(); + } + + // start payment processor + if(clusterConfig.PaymentProcessing?.Enabled == true && + clusterConfig.Pools.Any(x => x.PaymentProcessing?.Enabled == true)) + { + payoutManager = container.Resolve(); + payoutManager.Configure(clusterConfig); + + payoutManager.Start(); + } + + else + logger.Info("Payment processing is not enabled"); + + if(clusterConfig.ShareRelay == null) + { + // start pool stats updater + statsRecorder = container.Resolve(); + statsRecorder.Configure(clusterConfig); + statsRecorder.Start(); + } + + // start pools + await Task.WhenAll(clusterConfig.Pools.Where(x => x.Enabled).Select(async poolConfig => + { + // resolve pool implementation + var poolImpl = container.Resolve>>>() + .First(x => x.Value.Metadata.SupportedFamilies.Contains(poolConfig.Template.Family)).Value; + + // create and configure + var pool = poolImpl.Value; + pool.Configure(poolConfig, clusterConfig); + pools[poolConfig.Id] = pool; + + // pre-start attachments + shareReceiver?.AttachPool(pool); + statsRecorder?.AttachPool(pool); + + await pool.StartAsync(ct); + })); + } - Shutdown(); + else + await RecoverSharesAsync(shareRecoveryOption.Value()); + } - Process.GetCurrentProcess().Kill(); + private Task RecoverSharesAsync(string recoveryFilename) + { + shareRecorder = container.Resolve(); + return shareRecorder.RecoverSharesAsync(clusterConfig, recoveryFilename); } private static void LogRuntimeInfo() @@ -191,8 +394,7 @@ private static void ValidateConfig() // set some defaults foreach(var config in clusterConfig.Pools) { - if(!config.EnableInternalStratum.HasValue) - config.EnableInternalStratum = clusterConfig.ShareRelays == null || clusterConfig.ShareRelays.Length == 0; + config.EnableInternalStratum ??= clusterConfig.ShareRelays == null || clusterConfig.ShareRelays.Length == 0; } try @@ -218,11 +420,11 @@ private static void DumpParsedConfig(ClusterConfig config) })); } - private static bool HandleCommandLineOptions(string[] args, out string configFile) + private static bool ParseCommandLine(string[] args, out string configFile) { configFile = null; - var app = new CommandLineApplication(false) + var app = new CommandLineApplication { FullName = "MiningCore - Pool Mining Engine", ShortVersionGetter = () => $"v{Assembly.GetEntryAssembly().GetName().Version}", @@ -258,30 +460,6 @@ private static bool HandleCommandLineOptions(string[] args, out string configFil return true; } - private static void Bootstrap() - { - ZcashNetworks.Instance.EnsureRegistered(); - - // Service collection - var builder = new ContainerBuilder(); - - builder.RegisterAssemblyModules(typeof(AutofacModule).GetTypeInfo().Assembly); - builder.RegisterInstance(clusterConfig); - builder.RegisterInstance(pools); - builder.RegisterInstance(gcStats); - - // AutoMapper - var amConf = new MapperConfiguration(cfg => { cfg.AddProfile(new AutoMapperProfile()); }); - builder.Register((ctx, parms) => amConf.CreateMapper()); - - ConfigurePersistence(builder); - container = builder.Build(); - ConfigureLogging(); - ConfigureMisc(); - ValidateRuntimeEnvironment(); - MonitorGc(); - } - private static ClusterConfig ReadConfig(string file) { try @@ -390,23 +568,23 @@ private static void MonitorGc() private static void Logo() { - Console.WriteLine($@" + Console.WriteLine(@" ███╗ ███╗██╗███╗ ██╗██╗███╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗ ████╗ ████║██║████╗ ██║██║████╗ ██║██╔════╝ ██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔████╔██║██║██╔██╗ ██║██║██╔██╗ ██║██║ ███╗██║ ██║ ██║██████╔╝█████╗ ██║╚██╔╝██║██║██║╚██╗██║██║██║╚██╗██║██║ ██║██║ ██║ ██║██╔══██╗██╔══╝ ██║ ╚═╝ ██║██║██║ ╚████║██║██║ ╚████║╚██████╔╝╚██████╗╚██████╔╝██║ ██║███████╗ "); - Console.WriteLine($" https://github.com/coinfoundry/miningcore\n"); - Console.WriteLine($" Please contribute to the development of the project by donating:\n"); - Console.WriteLine($" BTC - 17QnVor1B6oK1rWnVVBrdX9gFzVkZZbhDm"); - Console.WriteLine($" LTC - LTK6CWastkmBzGxgQhTTtCUjkjDA14kxzC"); - Console.WriteLine($" DASH - XqpBAV9QCaoLnz42uF5frSSfrJTrqHoxjp"); - Console.WriteLine($" ZEC - t1YHZHz2DGVMJiggD2P4fBQ2TAPgtLSUwZ7"); - Console.WriteLine($" ZCL - t1MFU1vD3YKgsK6Uh8hW7UTY8mKAV2xVqBr"); - Console.WriteLine($" ETH - 0xcb55abBfe361B12323eb952110cE33d5F28BeeE1"); - Console.WriteLine($" ETC - 0xF8cCE9CE143C68d3d4A7e6bf47006f21Cfcf93c0"); - Console.WriteLine($" XMR - 475YVJbPHPedudkhrcNp1wDcLMTGYusGPF5fqE7XjnragVLPdqbCHBdZg3dF4dN9hXMjjvGbykS6a77dTAQvGrpiQqHp2eH"); + Console.WriteLine(" https://github.com/coinfoundry/miningcore\n"); + Console.WriteLine(" Please contribute to the development of the project by donating:\n"); + Console.WriteLine(" BTC - 17QnVor1B6oK1rWnVVBrdX9gFzVkZZbhDm"); + Console.WriteLine(" LTC - LTK6CWastkmBzGxgQhTTtCUjkjDA14kxzC"); + Console.WriteLine(" DASH - XqpBAV9QCaoLnz42uF5frSSfrJTrqHoxjp"); + Console.WriteLine(" ZEC - t1YHZHz2DGVMJiggD2P4fBQ2TAPgtLSUwZ7"); + Console.WriteLine(" ZCL - t1MFU1vD3YKgsK6Uh8hW7UTY8mKAV2xVqBr"); + Console.WriteLine(" ETH - 0xcb55abBfe361B12323eb952110cE33d5F28BeeE1"); + Console.WriteLine(" ETC - 0xF8cCE9CE143C68d3d4A7e6bf47006f21Cfcf93c0"); + Console.WriteLine(" XMR - 475YVJbPHPedudkhrcNp1wDcLMTGYusGPF5fqE7XjnragVLPdqbCHBdZg3dF4dN9hXMjjvGbykS6a77dTAQvGrpiQqHp2eH"); Console.WriteLine(); } @@ -419,20 +597,18 @@ private static void ConfigureLogging() { // parse level var level = !string.IsNullOrEmpty(config.Level) - ? LogLevel.FromString(config.Level) - : LogLevel.Info; + ? NLog.LogLevel.FromString(config.Level) + : NLog.LogLevel.Info; var layout = "[${longdate}] [${level:format=FirstCharacter:uppercase=true}] [${logger:shortName=true}] ${message} ${exception:format=ToString,StackTrace}"; - var nullTarget = new NullTarget("null") - { - }; + var nullTarget = new NullTarget("null"); loggingConfig.AddTarget(nullTarget); // Suppress some Aspnet stuff - loggingConfig.AddRule(level, LogLevel.Info, nullTarget, "Microsoft.AspNetCore.Mvc.Internal.*", true); - loggingConfig.AddRule(level, LogLevel.Info, nullTarget, "Microsoft.AspNetCore.Mvc.Infrastructure.*", true); + loggingConfig.AddRule(level, NLog.LogLevel.Info, nullTarget, "Microsoft.AspNetCore.Mvc.Internal.*", true); + loggingConfig.AddRule(level, NLog.LogLevel.Info, nullTarget, "Microsoft.AspNetCore.Mvc.Infrastructure.*", true); // Api Log if(!string.IsNullOrEmpty(config.ApiLogFile) && !isShareRecoveryMode) @@ -445,7 +621,7 @@ private static void ConfigureLogging() }; loggingConfig.AddTarget(target); - loggingConfig.AddRule(level, LogLevel.Fatal, target, "Microsoft.AspNetCore.*", true); + loggingConfig.AddRule(level, NLog.LogLevel.Fatal, target, "Microsoft.AspNetCore.*", true); } if(config.EnableConsoleLog || isShareRecoveryMode) @@ -482,7 +658,7 @@ private static void ConfigureLogging() ConsoleOutputColor.DarkRed, ConsoleOutputColor.White)); loggingConfig.AddTarget(target); - loggingConfig.AddRule(level, LogLevel.Fatal, target); + loggingConfig.AddRule(level, NLog.LogLevel.Fatal, target); } else @@ -493,7 +669,7 @@ private static void ConfigureLogging() }; loggingConfig.AddTarget(target); - loggingConfig.AddRule(level, LogLevel.Fatal, target); + loggingConfig.AddRule(level, NLog.LogLevel.Fatal, target); } } @@ -507,7 +683,7 @@ private static void ConfigureLogging() }; loggingConfig.AddTarget(target); - loggingConfig.AddRule(level, LogLevel.Fatal, target); + loggingConfig.AddRule(level, NLog.LogLevel.Fatal, target); } if(config.PerPoolLogFile && !isShareRecoveryMode) @@ -522,7 +698,7 @@ private static void ConfigureLogging() }; loggingConfig.AddTarget(target); - loggingConfig.AddRule(level, LogLevel.Fatal, target, poolConfig.Id); + loggingConfig.AddRule(level, NLog.LogLevel.Fatal, target, poolConfig.Id); } } } @@ -542,6 +718,8 @@ private static Layout GetLogPath(ClusterLoggingConfig config, string name) private static void ConfigureMisc() { + ZcashNetworks.Instance.EnsureRegistered(); + // Configure Equihash if(clusterConfig.EquihashMaxThreads.HasValue) EquihashSolver.MaxThreads = clusterConfig.EquihashMaxThreads.Value; @@ -604,7 +782,7 @@ private static void ConfigureDummyPersistence(ContainerBuilder builder) .SingleInstance(); } - private static Dictionary LoadCoinTemplates() + private Dictionary LoadCoinTemplates() { var basePath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); var defaultTemplates = Path.Combine(basePath, "coins.json"); @@ -624,7 +802,7 @@ private static Dictionary LoadCoinTemplates() private static void UseIpWhiteList(IApplicationBuilder app, bool defaultToLoopback, string[] locations, string[] whitelist) { - var ipList = whitelist?.Select(x => IPAddress.Parse(x)).ToList(); + var ipList = whitelist?.Select(IPAddress.Parse).ToList(); if(defaultToLoopback && (ipList == null || ipList.Count == 0)) ipList = new List(new[] { IPAddress.Loopback, IPAddress.IPv6Loopback, IPUtils.IPv4LoopBackOnIPv6 }); @@ -676,7 +854,7 @@ private static void ConfigureIpRateLimitOptions(IpRateLimitOptions options) { rules = new List { - new RateLimitRule + new() { Endpoint = "*", Period = "1s", @@ -690,193 +868,6 @@ private static void ConfigureIpRateLimitOptions(IpRateLimitOptions options) logger.Info(() => $"API access limited to {(string.Join(", ", rules.Select(x => $"{x.Limit} requests per {x.Period}")))}, except from {string.Join(", ", options.IpWhitelist)}"); } - private static void StartApi() - { - var address = clusterConfig.Api?.ListenAddress != null - ? (clusterConfig.Api.ListenAddress != "*" ? IPAddress.Parse(clusterConfig.Api.ListenAddress) : IPAddress.Any) - : IPAddress.Parse("127.0.0.1"); - - var port = clusterConfig.Api?.Port ?? 4000; - var enableApiRateLimiting = !(clusterConfig.Api?.RateLimiting?.Disabled == true); - - webHost = WebHost.CreateDefaultBuilder() - .ConfigureLogging(logging => - { - // NLog - logging.ClearProviders(); - logging.AddNLog(); - - logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); - }) - .ConfigureServices(services => - { - // rate limiting - if(enableApiRateLimiting) - { - services.Configure(ConfigureIpRateLimitOptions); - services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); - } - - // Controllers - services.AddSingleton(); - services.AddSingleton(); - - // MVC - services.AddSingleton((IComponentContext) container); - services.AddSingleton(); - - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2) - .AddControllersAsServices() - .AddJsonOptions(options => - { - options.SerializerSettings.Formatting = Formatting.Indented; - }); - - // Gzip Compression - services.AddResponseCompression(); - - // Cors - services.AddCors(); - - // WebSockets - services.AddWebSocketManager(); - }) - .Configure(app => - { - if(enableApiRateLimiting) - app.UseIpRateLimiting(); - - app.UseMiddleware(); - - UseIpWhiteList(app, true, new[] { "/api/admin" }, clusterConfig.Api?.AdminIpWhitelist); - UseIpWhiteList(app, true, new[] { "/metrics" }, clusterConfig.Api?.MetricsIpWhitelist); - - app.UseResponseCompression(); - app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials()); - app.UseWebSockets(); - app.MapWebSocketManager("/notifications", app.ApplicationServices.GetService()); - app.UseMetricServer(); - app.UseMvc(); - }) - .UseKestrel(options => - { - options.Listen(address, clusterConfig.Api.Port, listenOptions => - { - if(clusterConfig.Api.SSLConfig?.Enabled == true) - listenOptions.UseHttps(clusterConfig.Api.SSLConfig.SSLPath, clusterConfig.Api.SSLConfig.SSLPassword); - }); - }) - .Build(); - - webHost.Start(); - - logger.Info(() => $"API Online @ {address}:{port}{(!enableApiRateLimiting ? " [rate-limiting disabled]" : string.Empty)}"); - logger.Info(() => $"Prometheus Metrics Online @ {address}:{port}/metrics"); - logger.Info(() => $"WebSocket notifications streaming @ {address}:{port}/notifications"); - } - - private static async Task Start() - { - var coinTemplates = LoadCoinTemplates(); - logger.Info($"{coinTemplates.Keys.Count} coins loaded from {string.Join(", ", clusterConfig.CoinTemplates)}"); - - // Populate pool configs with corresponding template - foreach(var poolConfig in clusterConfig.Pools.Where(x => x.Enabled)) - { - // Lookup coin definition - if(!coinTemplates.TryGetValue(poolConfig.Coin, out var template)) - logger.ThrowLogPoolStartupException($"Pool {poolConfig.Id} references undefined coin '{poolConfig.Coin}'"); - - poolConfig.Template = template; - } - - // Notifications - notificationService = container.Resolve(); - - // start btStream receiver - btStreamReceiver = container.Resolve(); - btStreamReceiver.Start(clusterConfig); - - if(clusterConfig.ShareRelay == null) - { - // start share recorder - shareRecorder = container.Resolve(); - shareRecorder.Start(clusterConfig); - - // start share receiver (for external shares) - shareReceiver = container.Resolve(); - shareReceiver.Start(clusterConfig); - } - - else - { - // start share relay - shareRelay = container.Resolve(); - shareRelay.Start(clusterConfig); - } - - // start API - if(clusterConfig.Api == null || clusterConfig.Api.Enabled) - { - StartApi(); - - metricsPublisher = container.Resolve(); - } - - // start payment processor - if(clusterConfig.PaymentProcessing?.Enabled == true && - clusterConfig.Pools.Any(x => x.PaymentProcessing?.Enabled == true)) - { - payoutManager = container.Resolve(); - payoutManager.Configure(clusterConfig); - - payoutManager.Start(); - } - - else - logger.Info("Payment processing is not enabled"); - - if(clusterConfig.ShareRelay == null) - { - // start pool stats updater - statsRecorder = container.Resolve(); - statsRecorder.Configure(clusterConfig); - statsRecorder.Start(); - } - - // start pools - await Task.WhenAll(clusterConfig.Pools.Where(x => x.Enabled).Select(async poolConfig => - { - // resolve pool implementation - var poolImpl = container.Resolve>>>() - .First(x => x.Value.Metadata.SupportedFamilies.Contains(poolConfig.Template.Family)).Value; - - // create and configure - var pool = poolImpl.Value; - pool.Configure(poolConfig, clusterConfig); - pools[poolConfig.Id] = pool; - - // pre-start attachments - shareReceiver?.AttachPool(pool); - statsRecorder?.AttachPool(pool); - //apiServer?.AttachPool(pool); - - await pool.StartAsync(cts.Token); - })); - - // keep running - await Observable.Never().ToTask(cts.Token); - } - - private static Task RecoverSharesAsync(string recoveryFilename) - { - shareRecorder = container.Resolve(); - return shareRecorder.RecoverSharesAsync(clusterConfig, recoveryFilename); - } - private static void OnAppDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) { if(logger != null) @@ -887,49 +878,5 @@ private static void OnAppDomainUnhandledException(object sender, UnhandledExcept Console.WriteLine("** AppDomain unhandled exception: {0}", e.ExceptionObject); } - - private static void OnCancelKeyPress(object sender, ConsoleCancelEventArgs e) - { - logger?.Info(() => "SIGINT received. Exiting."); - Console.WriteLine("SIGINT received. Exiting."); - - try - { - cts?.Cancel(); - } - catch - { - } - - e.Cancel = true; - } - - private static void OnProcessExit(object sender, EventArgs e) - { - logger?.Info(() => "SIGTERM received. Exiting."); - Console.WriteLine("SIGTERM received. Exiting."); - - try - { - cts?.Cancel(); - } - catch - { - } - } - - private static void Shutdown() - { - logger?.Info(() => "Shutdown ..."); - Console.WriteLine("Shutdown..."); - - foreach(var pool in pools.Values) - pool.Stop(); - - shareRelay?.Stop(); - shareReceiver?.Stop(); - shareRecorder?.Stop(); - statsRecorder?.Stop(); - } } } diff --git a/src/Miningcore/Serialization/HexToByteArrayJsonConverter.cs b/src/Miningcore/Serialization/HexToByteArrayJsonConverter.cs index cae7f0f1dc..2344aafb12 100644 --- a/src/Miningcore/Serialization/HexToByteArrayJsonConverter.cs +++ b/src/Miningcore/Serialization/HexToByteArrayJsonConverter.cs @@ -21,7 +21,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist { var str = (string) reader.Value; if(str.StartsWith("0x")) - str = str.Substring(2); + str = str[2..]; if(string.IsNullOrEmpty(str)) return null; diff --git a/src/Miningcore/Serialization/HexToIntegralTypeJsonConverter.cs b/src/Miningcore/Serialization/HexToIntegralTypeJsonConverter.cs index f86d8b3a95..fdeccc86f9 100644 --- a/src/Miningcore/Serialization/HexToIntegralTypeJsonConverter.cs +++ b/src/Miningcore/Serialization/HexToIntegralTypeJsonConverter.cs @@ -32,7 +32,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return default(T); if(str.StartsWith("0x")) - str = str.Substring(2); + str = str[2..]; if(typeof(T) == typeof(BigInteger)) return BigInteger.Parse("0" + str, NumberStyles.HexNumber); diff --git a/src/Miningcore/Stratum/StratumClient.cs b/src/Miningcore/Stratum/StratumClient.cs index 89368de931..c4f2f50de0 100644 --- a/src/Miningcore/Stratum/StratumClient.cs +++ b/src/Miningcore/Stratum/StratumClient.cs @@ -83,11 +83,11 @@ public StratumClient() private readonly Pipe receivePipe; private readonly BufferBlock sendQueue; private WorkerContextBase context; - private readonly Subject terminated = new Subject(); - private readonly CancellationTokenSource cts = new CancellationTokenSource(); + private readonly Subject terminated = new(); + private readonly CancellationTokenSource cts = new(); private bool expectingProxyHeader; - private static readonly JsonSerializer serializer = new JsonSerializer + private static readonly JsonSerializer serializer = new() { ContractResolver = new CamelCasePropertyNamesContractResolver() }; @@ -149,8 +149,8 @@ public void Run(Socket socket, await Task.WhenAny(tasks); // We are done with this client, make sure all tasks complete - receivePipe.Reader.Complete(); - receivePipe.Writer.Complete(); + await receivePipe.Reader.CompleteAsync(); + await receivePipe.Writer.CompleteAsync(); sendQueue.Complete(); // additional safety net to ensure remaining tasks don't linger @@ -243,7 +243,7 @@ private async ValueTask SendAsync(T payload) if(!await sendQueue.SendAsync(payload, ctsComposite.Token)) { - // this will force a disconnect down the line + // this will force a disconnect down the line throw new IOException($"Send queue stalled at {sendQueue.Count} of {SendQueueCapacity} items"); } } @@ -286,7 +286,7 @@ private async Task ProcessReceivePipeAsync(TcpProxyProtocolConfig proxyProtocol, var result = await receivePipe.Reader.ReadAsync(cts.Token); var buffer = result.Buffer; - SequencePosition? position = null; + SequencePosition? position; if(buffer.Length > MaxInboundRequestLength) throw new InvalidDataException($"Incoming data exceeds maximum of {MaxInboundRequestLength}"); @@ -334,11 +334,11 @@ private async Task SendMessage(object msg) var buffer = ArrayPool.Shared.Rent(MaxOutboundRequestLength); try - { - using(var stream = new MemoryStream(buffer, true)) + { + await using(var stream = new MemoryStream(buffer, true)) { - // serialize - using(var writer = new StreamWriter(stream, StratumConstants.Encoding, MaxOutboundRequestLength, true)) + // serialize + await using(var writer = new StreamWriter(stream, StratumConstants.Encoding, MaxOutboundRequestLength, true)) { serializer.Serialize(writer, msg); } @@ -393,7 +393,7 @@ private bool ProcessProxyHeader(ReadOnlySequence seq, TcpProxyProtocolConf if(line.StartsWith("PROXY ")) { - var proxyAddresses = proxyProtocol.ProxyAddresses?.Select(x => IPAddress.Parse(x)).ToArray(); + var proxyAddresses = proxyProtocol.ProxyAddresses?.Select(IPAddress.Parse).ToArray(); if(proxyAddresses == null || !proxyAddresses.Any()) proxyAddresses = new[] { IPAddress.Loopback, IPUtils.IPv4LoopBackOnIPv6, IPAddress.IPv6Loopback }; diff --git a/src/Miningcore/Stratum/StratumServer.cs b/src/Miningcore/Stratum/StratumServer.cs index d02261eb85..63d1256820 100644 --- a/src/Miningcore/Stratum/StratumServer.cs +++ b/src/Miningcore/Stratum/StratumServer.cs @@ -83,14 +83,14 @@ static StratumServer() } } - protected readonly Dictionary clients = new Dictionary(); - protected static readonly ConcurrentDictionary certs = new ConcurrentDictionary(); + protected readonly Dictionary clients = new(); + protected static readonly ConcurrentDictionary certs = new(); protected static readonly HashSet ignoredSocketErrors; protected static readonly MethodBase StreamWriterCtor = typeof(StreamWriter).GetConstructor(new[] { typeof(Stream), typeof(Encoding), typeof(int), typeof(bool) }); protected readonly IComponentContext ctx; protected readonly IMasterClock clock; - protected readonly Dictionary ports = new Dictionary(); + protected readonly Dictionary ports = new(); protected ClusterConfig clusterConfig; protected IBanManager banManager; protected ILogger logger; diff --git a/src/Miningcore/Util/BigRational.cs b/src/Miningcore/Util/BigRational.cs index 913a53e989..800ee4f7d5 100644 --- a/src/Miningcore/Util/BigRational.cs +++ b/src/Miningcore/Util/BigRational.cs @@ -115,11 +115,11 @@ internal struct DecimalUInt32 #region Public Properties - public static BigRational Zero { get; } = new BigRational(BigInteger.Zero); + public static BigRational Zero { get; } = new(BigInteger.Zero); - public static BigRational One { get; } = new BigRational(BigInteger.One); + public static BigRational One { get; } = new(BigInteger.One); - public static BigRational MinusOne { get; } = new BigRational(BigInteger.MinusOne); + public static BigRational MinusOne { get; } = new(BigInteger.MinusOne); public int Sign => m_numerator.Sign; @@ -150,7 +150,7 @@ public BigInteger GetWholePart() public BigRational GetFractionPart() { - return new BigRational(BigInteger.Remainder(m_numerator, Denominator), Denominator); + return new(BigInteger.Remainder(m_numerator, Denominator), Denominator); } public override bool Equals(object obj) @@ -336,12 +336,12 @@ public static BigRational Abs(BigRational r) public static BigRational Negate(BigRational r) { - return new BigRational(BigInteger.Negate(r.m_numerator), r.Denominator); + return new(BigInteger.Negate(r.m_numerator), r.Denominator); } public static BigRational Invert(BigRational r) { - return new BigRational(r.Denominator, r.m_numerator); + return new(r.Denominator, r.m_numerator); } public static BigRational Add(BigRational x, BigRational y) @@ -470,7 +470,7 @@ public static int Compare(BigRational r1, BigRational r2) public static BigRational operator -(BigRational r) { - return new BigRational(-r.m_numerator, r.Denominator); + return new(-r.m_numerator, r.Denominator); } public static BigRational operator ++(BigRational r) @@ -486,33 +486,33 @@ public static int Compare(BigRational r1, BigRational r2) public static BigRational operator +(BigRational r1, BigRational r2) { // a/b + c/d == (ad + bc)/bd - return new BigRational(r1.m_numerator * r2.Denominator + r1.Denominator * r2.m_numerator, + return new(r1.m_numerator * r2.Denominator + r1.Denominator * r2.m_numerator, r1.Denominator * r2.Denominator); } public static BigRational operator -(BigRational r1, BigRational r2) { // a/b - c/d == (ad - bc)/bd - return new BigRational(r1.m_numerator * r2.Denominator - r1.Denominator * r2.m_numerator, + return new(r1.m_numerator * r2.Denominator - r1.Denominator * r2.m_numerator, r1.Denominator * r2.Denominator); } public static BigRational operator *(BigRational r1, BigRational r2) { // a/b * c/d == (ac)/(bd) - return new BigRational(r1.m_numerator * r2.m_numerator, r1.Denominator * r2.Denominator); + return new(r1.m_numerator * r2.m_numerator, r1.Denominator * r2.Denominator); } public static BigRational operator /(BigRational r1, BigRational r2) { // a/b / c/d == (ad)/(bc) - return new BigRational(r1.m_numerator * r2.Denominator, r1.Denominator * r2.m_numerator); + return new(r1.m_numerator * r2.Denominator, r1.Denominator * r2.m_numerator); } public static BigRational operator %(BigRational r1, BigRational r2) { // a/b % c/d == (ad % bc)/bd - return new BigRational(r1.m_numerator * r2.Denominator % (r1.Denominator * r2.m_numerator), + return new(r1.m_numerator * r2.Denominator % (r1.Denominator * r2.m_numerator), r1.Denominator * r2.Denominator); } @@ -657,65 +657,65 @@ public static explicit operator decimal(BigRational value) [CLSCompliant(false)] public static implicit operator BigRational(sbyte value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } [CLSCompliant(false)] public static implicit operator BigRational(ushort value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } [CLSCompliant(false)] public static implicit operator BigRational(uint value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } [CLSCompliant(false)] public static implicit operator BigRational(ulong value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } public static implicit operator BigRational(byte value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } public static implicit operator BigRational(short value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } public static implicit operator BigRational(int value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } public static implicit operator BigRational(long value) { - return new BigRational((BigInteger) value); + return new((BigInteger) value); } public static implicit operator BigRational(BigInteger value) { - return new BigRational(value); + return new(value); } public static implicit operator BigRational(float value) { - return new BigRational(value); + return new(value); } public static implicit operator BigRational(double value) { - return new BigRational(value); + return new(value); } public static implicit operator BigRational(decimal value) { - return new BigRational(value); + return new(value); } #endregion implicit conversions to BigRational diff --git a/src/Miningcore/Util/StaticRandom.cs b/src/Miningcore/Util/StaticRandom.cs index bb50d93159..789abe8aa1 100644 --- a/src/Miningcore/Util/StaticRandom.cs +++ b/src/Miningcore/Util/StaticRandom.cs @@ -10,7 +10,7 @@ public static class StaticRandom static int seed = Environment.TickCount; private static readonly ThreadLocal random = - new ThreadLocal(() => new Random(Interlocked.Increment(ref seed))); + new(() => new Random(Interlocked.Increment(ref seed))); public static int Next() { diff --git a/src/Miningcore/coins.json b/src/Miningcore/coins.json index 6701fb1178..6f77de3c74 100644 --- a/src/Miningcore/coins.json +++ b/src/Miningcore/coins.json @@ -13,9 +13,10 @@ "hash": "reverse", "args": [ { "hash": "sha256d" } ] }, - "explorerBlockLink": "https://blockchain.info/block/$height$", - "explorerTxLink": "https://blockchain.info/tx/{0}", - "explorerAccountLink": "https://blockchain.info/address/{0}" + "coinbaseIgnoreAuxFlags": true, // since Release 0.20 + "explorerBlockLink": "https://www.blockchain.com/btc/block/$hash$", + "explorerTxLink": "https://www.blockchain.com/btc/tx/{0}", + "explorerAccountLink": "https://www.blockchain.com/btc/address/{0}" }, "bitcoin-cash": { "name": "Bitcoin Cash", @@ -31,9 +32,9 @@ "hash": "reverse", "args": [ { "hash": "sha256d" } ] }, - "explorerBlockLink": "https://www.blocktrail.com/BCC/block/$height$", - "explorerTxLink": "https://www.blocktrail.com/BCC/tx/{0}", - "explorerAccountLink": "https://www.blocktrail.com/BCC/address/{0}" + "explorerBlockLink": "https://www.blockchain.com/bch/block/$hash$", + "explorerTxLink": "https://www.blockchain.com/bch/tx/{0}", + "explorerAccountLink": "https://www.blockchain.com/bch/address/{0}" }, "namecoin": { "name": "Namecoin", @@ -118,8 +119,8 @@ "explorerTxLink": "https://chainz.cryptoid.info/lcc/tx.dws?{0}.htm", "explorerAccountLink": "https://chainz.cryptoid.info/lcc/address.dws?{0}.htm" }, - "dogecoin,": { - "name": "Dogecoin,", + "dogecoin": { + "name": "Dogecoin", "symbol": "DOGE", "family": "bitcoin", "coinbaseHasher": { @@ -464,6 +465,7 @@ "hash": "reverse", "args": [ { "hash": "sha256d" } ] }, + "blockTemplateRpcExtraParams": [ "sha256" ], "explorerBlockLink": "https://digiexplorer.info/block/$height$", "explorerTxLink": "https://digiexplorer.info/tx/{0}", "explorerAccountLink": "https://digiexplorer.info/address/{0}" @@ -485,6 +487,7 @@ "args": [ { "hash": "sha256d" } ] }, "shareMultiplier": 65536, + "blockTemplateRpcExtraParams": [ "scrypt" ], "explorerBlockLink": "https://digiexplorer.info/block/$height$", "explorerTxLink": "https://digiexplorer.info/tx/{0}", "explorerAccountLink": "https://digiexplorer.info/address/{0}" @@ -504,6 +507,7 @@ "hash": "reverse", "args": [ { "hash": "sha256d" } ] }, + "blockTemplateRpcExtraParams": [ "skein" ], "explorerBlockLink": "https://digiexplorer.info/block/$height$", "explorerTxLink": "https://digiexplorer.info/tx/{0}", "explorerAccountLink": "https://digiexplorer.info/address/{0}" @@ -523,6 +527,7 @@ "hash": "reverse", "args": [ { "hash": "sha256d" } ] }, + "blockTemplateRpcExtraParams": [ "qubit" ], "explorerBlockLink": "https://digiexplorer.info/block/$height$", "explorerTxLink": "https://digiexplorer.info/tx/{0}", "explorerAccountLink": "https://digiexplorer.info/address/{0}" @@ -547,37 +552,6 @@ "explorerTxLink": "https://digiexplorer.info/tx/{0}", "explorerAccountLink": "https://digiexplorer.info/address/{0}" }, - "digibyte-odo": { - "name": "Digibyte-Odo", - "canonicalName": "Digibyte", - "symbol": "DGB", - "family": "bitcoin", - "coinbaseHasher": { - "hash": "sha256s" - }, - "headerHasher": { - "hash": "odocrypt" - }, - "blockHasher": { - "hash": "reverse", - "args": [ { "hash": "sha256d" } ] - }, - "networks": { - "main": { - "odoCryptShapeChangeInterval": 864000 - }, - "test": { - "odoCryptShapeChangeInterval": 86400 - }, - "regtest": { - "odoCryptShapeChangeInterval": 60 - } - }, - "shareMultiplier": 256, - "explorerBlockLink": "https://digiexplorer.info/block/$height$", - "explorerTxLink": "https://digiexplorer.info/tx/{0}", - "explorerAccountLink": "https://digiexplorer.info/address/{0}" - }, "verge-lyra": { "name": "Verge-Lyra", "canonicalName": "Verge", @@ -598,6 +572,8 @@ } ] }, + "isPseudoPoS": true, + "blockTemplateRpcExtraParams": [ "lyra" ], "shareMultiplier": 256, "explorerBlockLink": "https://verge-blockchain.info/block/$hash$", "explorerTxLink": "https://verge-blockchain.info/tx/{0}", @@ -624,6 +600,8 @@ } ] }, + "isPseudoPoS": true, + "blockTemplateRpcExtraParams": ["scrypt"], "shareMultiplier": 65536, "explorerBlockLink": "https://verge-blockchain.info/block/$hash$", "explorerTxLink": "https://verge-blockchain.info/tx/{0}", @@ -649,6 +627,8 @@ } ] }, + "isPseudoPoS": true, + "blockTemplateRpcExtraParams": [ "x17" ], "explorerBlockLink": "https://verge-blockchain.info/block/$hash$", "explorerTxLink": "https://verge-blockchain.info/tx/{0}", "explorerAccountLink": "https://verge-blockchain.info/address/{0}" @@ -673,6 +653,8 @@ } ] }, + "isPseudoPoS": true, + "blockTemplateRpcExtraParams": [ "blake" ], "explorerBlockLink": "https://verge-blockchain.info/block/$hash$", "explorerTxLink": "https://verge-blockchain.info/tx/{0}", "explorerAccountLink": "https://verge-blockchain.info/address/{0}" @@ -697,6 +679,8 @@ } ] }, + "isPseudoPoS": true, + "blockTemplateRpcExtraParams": [ "groestl" ], "explorerBlockLink": "https://verge-blockchain.info/block/$hash$", "explorerTxLink": "https://verge-blockchain.info/tx/{0}", "explorerAccountLink": "https://verge-blockchain.info/address/{0}" @@ -1262,114 +1246,20 @@ "explorerTxLink": "https://minexexplorer.com/transactions/view?hash={0}", "explorerAccountLink": "https://minexexplorer.com/address?hash={0}" }, - "bitcoin-private": { - "name": "Bitcoin Private", - "symbol": "BTCP", - "family": "equihash", - "networks": { - "main": { - "diff1": "0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "solutionSize": 1344, - "solutionPreambleSize": 3, - "solver": { - "hash": "equihash", - "args": [ 200, 9, "ZcashPoW" ] - }, - "coinbaseTxNetwork": "main", - "payFoundersReward": false - }, - "test": { - "diff1": "0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "solutionSize": 1344, - "solutionPreambleSize": 3, - "solver": { - "hash": "equihash", - "args": [ 200, 9, "ZcashPoW" ] - }, - "coinbaseTxNetwork": "testnet", - "payFoundersReward": false - }, - "regtest": { - "diff1": "0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "solutionSize": 1344, - "solutionPreambleSize": 3, - "solver": { - "hash": "equihash", - "args": [ 200, 9, "ZcashPoW" ] - }, - "coinbaseTxNetwork": "regtest", - "payFoundersReward": false - } - }, - "usesZCashAddressFormat": true, - "useBitcoinPayoutHandler": false, - "explorerBlockLink": "https://explorer.btcprivate.org/block-index/$hash$", - "explorerTxLink": "https://explorer.btcprivate.org/tx/{0}", - "explorerAccountLink": "https://explorer.btcprivate.org/address/{0}" - }, "monero": { "name": "Monero", "symbol": "XMR", "family": "cryptonote", - "hash": "cryptonight", + "hash": "randomx", "hashVariant": 0, "smallestUnit": 1000000000000, "addressPrefix": 18, + "addressPrefixStagenet": 24, "addressPrefixTestnet": 53, "addressPrefixIntegrated": 19, + "addressPrefixIntegratedStagenet": 25, "addressPrefixIntegratedTestnet": 54, - "explorerBlockLink": "https://chainradar.com/xmr/block/$height$", - "explorerTxLink": "https://chainradar.com/xmr/transaction/{0}" - }, - "bittube": { - "name": "Bittube", - "symbol": "TUBE", - "family": "cryptonote", - "hash": "cryptonight-heavy", - "hashVariant": 2, - "smallestUnit": 100000000, - "addressPrefix": 209, - "addressPrefixTestnet": 209, - "addressPrefixIntegrated": 16463, - "addressPrefixIntegratedTestnet": 16463, - "blockrewardMultiplier": 0.7, - "explorerBlockLink": "https://explorer.bit.tube/block/$height$", - "explorerTxLink": "https://explorer.bit.tube/tx/{0}" - }, - "aeon": { - "name": "Aeon", - "symbol": "AEON", - "family": "cryptonote", - "hash": "cryptonight-lite", - "hashVariant": 0, - "smallestUnit": 100000000, - "addressPrefix": 178, - "addressPrefixTestnet": 1062, - "addressPrefixIntegrated": 10035, - "addressPrefixIntegratedTestnet": 11303, - "explorerBlockLink": "https://aeonblocks.com/block/$height$", - "explorerTxLink": "https://aeonblocks.com/tx/{0}" - }, - "ethereum": { - "name": "Ethereum", - "symbol": "ETH", - "family": "ethereum", - "explorerBlockLinks": { - "block": "https://etherscan.io/block/$height$", - "uncle": "https://etherscan.io/uncle/$height$" - }, - "explorerTxLink": "https://etherscan.io/tx/{0}", - "explorerAccountLink": "https://etherscan.io/address/{0}" - }, - "ethereum-classic": { - "name": "Ethereum Classic", - "symbol": "ETC", - "family": "ethereum", - "explorerBlockLinks": { - "block": "https://gastracker.io/block/$height$", - "uncle": "https://gastracker.io/uncle/$height$" - }, - "explorerTxLink": "https://gastracker.io/tx/{0}", - "explorerAccountLink": "https://gastracker.io/addr/{0}" + "explorerBlockLink": "https://www.exploremonero.com/block/$height$", + "explorerTxLink": "https://www.exploremonero.com/transaction/{0}" } } diff --git a/src/Miningcore/linux-build.sh b/src/Miningcore/linux-build.sh index a388944807..59299ef8d9 100755 --- a/src/Miningcore/linux-build.sh +++ b/src/Miningcore/linux-build.sh @@ -5,4 +5,4 @@ BUILDIR=${1:-../../build} echo "Building into $BUILDIR" -dotnet publish -c Release --framework netcoreapp2.2 -o $BUILDIR +dotnet publish -c Release --framework net5.0 -o $BUILDIR diff --git a/src/Miningcore/windows-build.bat b/src/Miningcore/windows-build.bat index 63cfbe768f..071bf25e1d 100644 --- a/src/Miningcore/windows-build.bat +++ b/src/Miningcore/windows-build.bat @@ -1 +1 @@ -dotnet publish -c Release --framework netcoreapp2.1 -o ../../build +dotnet publish -c Release --framework net5.0 -o ../../build diff --git a/src/Native/libcryptonight/Makefile b/src/Native/libcryptonight/Makefile deleted file mode 100644 index 3b6aa70cfa..0000000000 --- a/src/Native/libcryptonight/Makefile +++ /dev/null @@ -1,28 +0,0 @@ -CC = gcc -INC_DIRS = -Ixmrig -IIxmrig/3rdparty - -# Temporarily disable optimizations to debug crashes -CFLAGS = -g -Wall -c -fPIC -maes -O2 -fpermissive -Wno-fpermissive -Wno-strict-aliasing -Wno-sign-compare -DCPU_INTEL $(INC_DIRS) -CXXFLAGS = -g -Wall -maes -O2 -Wno-unused-function -fPIC -fpermissive -Wno-strict-aliasing -Wno-sign-compare -std=c++0x -fexceptions -frtti -DCPU_INTEL $(INC_DIRS) - -LDFLAGS = -shared -TARGET = libcryptonight.so - -OBJECTS = xmrig/crypto/asm/cn_main_loop.o xmrig/crypto/asm/CryptonightR_template.o \ - xmrig/crypto/cn_gpu_ssse3.o xmrig/common/cpu/Cpu.o xmrig/common/cpu/BasicCpuInfo.o \ - xmrig/extra.o xmrig/Mem.o xmrig/Mem_unix.o \ - xmrig/crypto/c_blake256.o xmrig/crypto/c_groestl.o xmrig/crypto/c_jh.o \ - xmrig/crypto/c_skein.o xmrig/common/crypto/keccak.o \ - xmrig/crypto/CryptonightR_gen.o \ - exports.o - -all: $(TARGET) - -$(TARGET): $(OBJECTS) - g++ $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) - -.PHONY: clean - -clean: - find . -name '*.o' -exec rm -r {} \; - rm -f libcryptonight.so diff --git a/src/Native/libcryptonight/dllmain.cpp b/src/Native/libcryptonight/dllmain.cpp deleted file mode 100644 index e1a53b99d3..0000000000 --- a/src/Native/libcryptonight/dllmain.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// dllmain.cpp : Defines the entry point for the DLL application. -#include "stdafx.h" - -BOOL APIENTRY DllMain( HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} diff --git a/src/Native/libcryptonight/exports.cpp b/src/Native/libcryptonight/exports.cpp deleted file mode 100644 index 45146c5642..0000000000 --- a/src/Native/libcryptonight/exports.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* -Copyright 2017 Coin Foundry (coinfoundry.org) -Authors: Oliver Weichhold (oliver@weichhold.com) -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and -associated documentation files (the "Software"), to deal in the Software without restriction, -including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: -The above copyright notice and this permission notice shall be included in all copies or substantial -portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include - -#if defined(__ARM_ARCH) -#include "xmrig/crypto/CryptoNight_arm.h" -#else -#include "xmrig/extra.h" -#include "xmrig/crypto/CryptoNight_x86.h" -#endif - -#include "xmrig/Mem.h" - -#if (defined(__AES__) && (__AES__ == 1)) || (defined(__ARM_FEATURE_CRYPTO) && (__ARM_FEATURE_CRYPTO == 1)) -#define SOFT_AES false -#else -// #warning Using software AES -#define SOFT_AES true -#endif - -#ifdef _WIN32 -#define MODULE_API __declspec(dllexport) -#else -#define MODULE_API -#endif - -#define STRINGISE_IMPL(x) #x -#define STRINGISE(x) STRINGISE_IMPL(x) - -extern "C" MODULE_API cryptonight_ctx *cryptonight_alloc_context_export() { - cryptonight_ctx *ctx = NULL; - Mem::create(&ctx, xmrig::CRYPTONIGHT, 1); - - return ctx; -} - -extern "C" MODULE_API cryptonight_ctx *cryptonight_alloc_lite_context_export() { - cryptonight_ctx *ctx = NULL; - Mem::create(&ctx, xmrig::CRYPTONIGHT_LITE, 1); - - return ctx; -} - -extern "C" MODULE_API cryptonight_ctx *cryptonight_alloc_heavy_context_export() { - cryptonight_ctx *ctx = NULL; - Mem::create(&ctx, xmrig::CRYPTONIGHT_HEAVY, 1); - - return ctx; -} - -extern "C" MODULE_API cryptonight_ctx *cryptonight_alloc_pico_context_export() { - cryptonight_ctx *ctx = NULL; - Mem::create(&ctx, xmrig::CRYPTONIGHT_PICO, 1); - - return ctx; -} - -extern "C" MODULE_API void cryptonight_free_ctx_export(cryptonight_ctx *ctx) { - MemInfo mi; - Mem::release(&ctx, 1, mi); -} - -extern "C" MODULE_API void cryptonight_export(cryptonight_ctx* ctx, const char* input, unsigned char *output, size_t inputSize, uint32_t variant, uint64_t height) -{ - switch (variant) { - case 0: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 1: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 3: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 4: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 6: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 7: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - - case 8: -#if !SOFT_AES && defined(CPU_INTEL) - // #warning Using IvyBridge assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD) - // #warning Using Ryzen assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - // #warning Using Bulldozer assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - - case 9: -#if !SOFT_AES && defined(CPU_INTEL) - // #warning Using IvyBridge assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD) - // #warning Using Ryzen assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - // #warning Using Bulldozer assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - case 11: cryptonight_single_hash_gpu(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 12: - //if (!height_set) return THROW_ERROR_EXCEPTION("CryptonightR requires block template height as Argument 3"); - -#if !SOFT_AES && (defined(CPU_INTEL) || defined(CPU_AMD)) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - case 13: - //if (!height_set) return THROW_ERROR_EXCEPTION("Cryptonight4 requires block template height as Argument 3"); - -#if !SOFT_AES && defined(CPU_INTEL) - // #warning Using IvyBridge assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD) - // #warning Using Ryzen assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - // #warning Using Bulldozer assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - - case 14: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - - case 15: -#if !SOFT_AES && defined(CPU_INTEL) - // #warning Using IvyBridge assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD) - // #warning Using Ryzen assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - // #warning Using Bulldozer assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - - case 16: -#if !SOFT_AES && defined(CPU_INTEL) - // #warning Using IvyBridge assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD) - // #warning Using Ryzen assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - // #warning Using Bulldozer assembler implementation - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); -#endif - break; - - default: cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - } -} - -extern "C" MODULE_API void cryptonight_light_export(cryptonight_ctx* ctx, const char* input, unsigned char *output, size_t inputSize, uint32_t variant, uint64_t height) -{ - switch (variant) { - case 0: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 1: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - default: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - } -} - -extern "C" MODULE_API void cryptonight_heavy_export(cryptonight_ctx* ctx, const char* input, unsigned char *output, size_t inputSize, uint32_t variant, uint64_t height) -{ - switch (variant) { - case 0: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 1: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - case 2: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - break; - default: - cryptonight_single_hash(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, height); - } -} - -extern "C" MODULE_API void cryptonight_pico_export(cryptonight_ctx* ctx, const char* input, unsigned char *output, size_t inputSize, uint32_t variant, uint64_t height) -{ - switch (variant) { - case 0: -#if !SOFT_AES && defined(CPU_INTEL) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#elif !SOFT_AES && defined(CPU_AMD) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#endif - break; - default: -#if !SOFT_AES && defined(CPU_INTEL) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#elif !SOFT_AES && defined(CPU_AMD) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#elif !SOFT_AES && defined(CPU_AMD_OLD) - cryptonight_single_hash_asm(reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#else - cryptonight_single_hash (reinterpret_cast(input), inputSize, reinterpret_cast(output), &ctx, 0); -#endif - } -} diff --git a/src/Native/libcryptonight/libcryptonight.sln b/src/Native/libcryptonight/libcryptonight.sln deleted file mode 100644 index 339208da21..0000000000 --- a/src/Native/libcryptonight/libcryptonight.sln +++ /dev/null @@ -1,31 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26720.2 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcryptonight", "libcryptonight.vcxproj", "{3D1C939F-36D2-4942-A125-2C7E6FF2833F}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Debug|x64.ActiveCfg = Debug|x64 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Debug|x64.Build.0 = Debug|x64 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Debug|x86.ActiveCfg = Debug|Win32 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Debug|x86.Build.0 = Debug|Win32 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Release|x64.ActiveCfg = Release|x64 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Release|x64.Build.0 = Release|x64 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Release|x86.ActiveCfg = Release|Win32 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {DDE0FE54-030A-4DFD-98A1-952779FB461F} - EndGlobalSection -EndGlobal diff --git a/src/Native/libcryptonight/libcryptonight.vcxproj b/src/Native/libcryptonight/libcryptonight.vcxproj deleted file mode 100644 index 633ea36053..0000000000 --- a/src/Native/libcryptonight/libcryptonight.vcxproj +++ /dev/null @@ -1,228 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 15.0 - {3D1C939F-36D2-4942-A125-2C7E6FF2833F} - Win32Proj - netmultihashnative - 10.0 - libcryptonight - - - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - - - DynamicLibrary - true - v142 - Unicode - - - DynamicLibrary - false - v142 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - true - $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(SolutionDir)\..\..\..\..\boost_1_62_0\lib32-msvc-14.0 - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)xmrig;$(IncludePath);$(ProjectDir)xmrig\3rdparty - - - true - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;$(SolutionDir)\..\..\..\..\boost_1_62_0\lib64-msvc-14.0 - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(ProjectDir)xmrig;$(IncludePath);$(ProjectDir)xmrig\3rdparty - - - false - $(VC_LibraryPath_x86);$(WindowsSDK_LibraryPath_x86);$(NETFXKitsDir)Lib\um\x86;$(SolutionDir)\..\..\..\..\boost_1_62_0\lib32-msvc-14.0 - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath);$(ProjectDir)xmrig;$(IncludePath);$(ProjectDir)xmrig\3rdparty - - - false - $(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;$(SolutionDir)\..\..\..\..\boost_1_62_0\lib64-msvc-14.0 - $(VC_IncludePath);$(WindowsSDK_IncludePath);$(IncludePath);$(ProjectDir)xmrig;$(IncludePath);$(ProjectDir)xmrig\3rdparty - - - - - - Level3 - Disabled - WIN32;_DEBUG;netmultihashnative_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);NEOSCRYPT_SHA256;NEOSCRYPT_BLAKE256;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGSWIN32_LEAN_AND_MEAN;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;__AES__=1 - true - MultiThreadedDebug - $(ProjectDir);$(ProjectDir)contrib\epee\include;;$(ProjectDir)contrib\easylogging;%(AdditionalIncludeDirectories) - true - - - Windows - true - - - - - - - Level3 - Disabled - _DEBUG;netmultihashnative_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);NEOSCRYPT_SHA256;NEOSCRYPT_BLAKE256;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGSWIN32_LEAN_AND_MEAN;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;__AES__=1;CPU_INTEL - true - MultiThreadedDebug - $(ProjectDir);$(ProjectDir)contrib\epee\include;;$(ProjectDir)contrib\easylogging;%(AdditionalIncludeDirectories) - true - - - Windows - true - - - - - - - Level3 - MaxSpeed - true - true - WIN32;NDEBUG;netmultihashnative_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);NEOSCRYPT_SHA256;NEOSCRYPT_BLAKE256;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGSWIN32_LEAN_AND_MEAN;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;__AES__=1 - true - MultiThreaded - $(ProjectDir);$(ProjectDir)contrib\epee\include;;$(ProjectDir)contrib\easylogging;%(AdditionalIncludeDirectories) - true - - - Windows - true - true - true - - - - - - - Level3 - MaxSpeed - true - true - NDEBUG;netmultihashnative_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);NEOSCRYPT_SHA256;NEOSCRYPT_BLAKE256;_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGSWIN32_LEAN_AND_MEAN;WIN32_LEAN_AND_MEAN;_CRT_SECURE_NO_WARNINGS;__AES__=1;CPU_INTEL - true - MultiThreaded - $(ProjectDir);$(ProjectDir)contrib\epee\include;;$(ProjectDir)contrib\easylogging;%(AdditionalIncludeDirectories) - true - - - Windows - true - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Document - - - Document - - - - - - - \ No newline at end of file diff --git a/src/Native/libcryptonight/stdafx.cpp b/src/Native/libcryptonight/stdafx.cpp deleted file mode 100644 index bd27597c6f..0000000000 --- a/src/Native/libcryptonight/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// $safeprojectname$.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/src/Native/libcryptonight/stdafx.h b/src/Native/libcryptonight/stdafx.h deleted file mode 100644 index 3a04bc9f66..0000000000 --- a/src/Native/libcryptonight/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#include "targetver.h" - -// Windows Header Files: -#include - - -// TODO: reference additional headers your program requires here diff --git a/src/Native/libcryptonight/targetver.h b/src/Native/libcryptonight/targetver.h deleted file mode 100644 index 90e767bfce..0000000000 --- a/src/Native/libcryptonight/targetver.h +++ /dev/null @@ -1,8 +0,0 @@ -#pragma once - -// Including SDKDDKVer.h defines the highest available Windows platform. - -// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and -// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. - -#include diff --git a/src/Native/libcryptonight/xmrig/3rdparty/aligned_malloc.h b/src/Native/libcryptonight/xmrig/3rdparty/aligned_malloc.h deleted file mode 100644 index 0b74b17e0a..0000000000 --- a/src/Native/libcryptonight/xmrig/3rdparty/aligned_malloc.h +++ /dev/null @@ -1,65 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2016-2017 XMRig - * - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __ALIGNED_MALLOC_H__ -#define __ALIGNED_MALLOC_H__ - - -#include - - -#ifndef __cplusplus -extern int posix_memalign(void **__memptr, size_t __alignment, size_t __size); -#else -// Some systems (e.g. those with GNU libc) declare posix_memalign with an -// exception specifier. Via an "egregious workaround" in -// Sema::CheckEquivalentExceptionSpec, Clang accepts the following as a valid -// redeclaration of glibc's declaration. -extern "C" int posix_memalign(void **__memptr, size_t __alignment, size_t __size); -#endif - - -static __inline__ void *__attribute__((__always_inline__, __malloc__)) _mm_malloc(size_t __size, size_t __align) -{ - if (__align == 1) { - return malloc(__size); - } - - if (!(__align & (__align - 1)) && __align < sizeof(void *)) - __align = sizeof(void *); - - void *__mallocedMemory; - if (posix_memalign(&__mallocedMemory, __align, __size)) { - return 0; - } - - return __mallocedMemory; -} - - -static __inline__ void __attribute__((__always_inline__)) _mm_free(void *__p) -{ - free(__p); -} - -#endif /* __ALIGNED_MALLOC_H__ */ diff --git a/src/Native/libcryptonight/xmrig/Mem.cpp b/src/Native/libcryptonight/xmrig/Mem.cpp deleted file mode 100644 index 4fa794d65c..0000000000 --- a/src/Native/libcryptonight/xmrig/Mem.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include "common/utils/mm_malloc.h" -#include "crypto/CryptoNight.h" -#include "crypto/CryptoNight_constants.h" -#include "Mem.h" - - -bool Mem::m_enabled = true; -int Mem::m_flags = 0; - - -MemInfo Mem::create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count) -{ - using namespace xmrig; - - MemInfo info; - info.size = cn_select_memory(algorithm) * count; - - constexpr const size_t align_size = 2 * 1024 * 1024; - info.size = ((info.size + align_size - 1) / align_size) * align_size; - info.pages = info.size / align_size; - - allocate(info, m_enabled); - - for (size_t i = 0; i < count; ++i) { - cryptonight_ctx *c = static_cast(_mm_malloc(sizeof(cryptonight_ctx), 4096)); - c->memory = info.memory + (i * cn_select_memory(algorithm)); - - uint8_t* p = reinterpret_cast(allocateExecutableMemory(0x4000)); - c->generated_code = reinterpret_cast(p); - c->generated_code_double = reinterpret_cast(p + 0x2000); - - c->generated_code_data.variant = xmrig::VARIANT_MAX; - c->generated_code_data.height = (uint64_t)(-1); - c->generated_code_double_data = c->generated_code_data; - - ctx[i] = c; - } - - return info; -} - - -void Mem::release(cryptonight_ctx **ctx, size_t count, MemInfo &info) -{ - release(info); - - for (size_t i = 0; i < count; ++i) { - _mm_free(ctx[i]); - } -} - diff --git a/src/Native/libcryptonight/xmrig/Mem.h b/src/Native/libcryptonight/xmrig/Mem.h deleted file mode 100644 index 9e39e963cb..0000000000 --- a/src/Native/libcryptonight/xmrig/Mem.h +++ /dev/null @@ -1,78 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_MEM_H -#define XMRIG_MEM_H - - -#include -#include - - -#include "common/xmrig.h" - - -struct cryptonight_ctx; - - -struct MemInfo -{ - alignas(16) uint8_t *memory; - - size_t hugePages; - size_t pages; - size_t size; -}; - - -class Mem -{ -public: - enum Flags { - HugepagesAvailable = 1, - HugepagesEnabled = 2, - Lock = 4 - }; - - static MemInfo create(cryptonight_ctx **ctx, xmrig::Algo algorithm, size_t count); - static void init(bool enabled); - static void release(cryptonight_ctx **ctx, size_t count, MemInfo &info); - - static void *allocateExecutableMemory(size_t size); - static void protectExecutableMemory(void *p, size_t size); - static void flushInstructionCache(void *p, size_t size); - - static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; } - -private: - static void allocate(MemInfo &info, bool enabled); - static void release(MemInfo &info); - - static int m_flags; - static bool m_enabled; -}; - - -#endif /* XMRIG_MEM_H */ diff --git a/src/Native/libcryptonight/xmrig/Mem_unix.cpp b/src/Native/libcryptonight/xmrig/Mem_unix.cpp deleted file mode 100644 index a1bec3d4f2..0000000000 --- a/src/Native/libcryptonight/xmrig/Mem_unix.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include - - -#include "common/utils/mm_malloc.h" -#include "common/xmrig.h" -#include "crypto/CryptoNight.h" -#include "Mem.h" - - -void Mem::init(bool enabled) -{ - m_enabled = enabled; -} - - -void Mem::allocate(MemInfo &info, bool enabled) -{ - info.hugePages = 0; - - if (!enabled) { - info.memory = static_cast(_mm_malloc(info.size, 4096)); - - return; - } - -# if defined(__APPLE__) - info.memory = static_cast(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, VM_FLAGS_SUPERPAGE_SIZE_2MB, 0)); -# elif defined(__FreeBSD__) - info.memory = static_cast(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER | MAP_PREFAULT_READ, -1, 0)); -# else - info.memory = static_cast(mmap(0, info.size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB | MAP_POPULATE, 0, 0)); -# endif - - if (info.memory == MAP_FAILED) { - return allocate(info, false);; - } - - info.hugePages = info.pages; - - if (madvise(info.memory, info.size, MADV_RANDOM | MADV_WILLNEED) != 0) { - //LOG_ERR("madvise failed"); - } - - if (mlock(info.memory, info.size) == 0) { - m_flags |= Lock; - } -} - - -void Mem::release(MemInfo &info) -{ - if (info.hugePages) { - if (m_flags & Lock) { - munlock(info.memory, info.size); - } - - munmap(info.memory, info.size); - } - else { - _mm_free(info.memory); - } -} - - -void *Mem::allocateExecutableMemory(size_t size) -{ -# if defined(__APPLE__) - return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON, -1, 0); -# else - return mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -# endif -} - - -void Mem::protectExecutableMemory(void *p, size_t size) -{ - mprotect(p, size, PROT_READ | PROT_EXEC); -} - - -void Mem::flushInstructionCache(void *p, size_t size) -{ -# ifndef __FreeBSD__ - __builtin___clear_cache(reinterpret_cast(p), reinterpret_cast(p) + size); -# endif -} diff --git a/src/Native/libcryptonight/xmrig/Mem_win.cpp b/src/Native/libcryptonight/xmrig/Mem_win.cpp deleted file mode 100644 index 372ed5fa40..0000000000 --- a/src/Native/libcryptonight/xmrig/Mem_win.cpp +++ /dev/null @@ -1,204 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include -#include -#include - - -//#include "common/log/Log.h" -#include "common/utils/mm_malloc.h" -#include "common/xmrig.h" -#include "crypto/CryptoNight.h" -#include "crypto/CryptoNight_constants.h" -#include "Mem.h" - - -/***************************************************************** -SetLockPagesPrivilege: a function to obtain or -release the privilege of locking physical pages. - -Inputs: - -HANDLE hProcess: Handle for the process for which the -privilege is needed - -BOOL bEnable: Enable (TRUE) or disable? - -Return value: TRUE indicates success, FALSE failure. - -*****************************************************************/ -/** - * AWE Example: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366531(v=vs.85).aspx - * Creating a File Mapping Using Large Pages: https://msdn.microsoft.com/en-us/library/aa366543(VS.85).aspx - */ -static BOOL SetLockPagesPrivilege() { - HANDLE token; - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &token) != TRUE) { - return FALSE; - } - - TOKEN_PRIVILEGES tp; - tp.PrivilegeCount = 1; - tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - - if (LookupPrivilegeValue(NULL, SE_LOCK_MEMORY_NAME, &(tp.Privileges[0].Luid)) != TRUE) { - return FALSE; - } - - BOOL rc = AdjustTokenPrivileges(token, FALSE, (PTOKEN_PRIVILEGES) &tp, 0, NULL, NULL); - if (rc != TRUE || GetLastError() != ERROR_SUCCESS) { - return FALSE; - } - - CloseHandle(token); - - return TRUE; -} - - -static LSA_UNICODE_STRING StringToLsaUnicodeString(LPCTSTR string) { - LSA_UNICODE_STRING lsaString; - - DWORD dwLen = (DWORD) wcslen(string); - lsaString.Buffer = (LPWSTR) string; - lsaString.Length = (USHORT)((dwLen) * sizeof(WCHAR)); - lsaString.MaximumLength = (USHORT)((dwLen + 1) * sizeof(WCHAR)); - return lsaString; -} - - -static BOOL ObtainLockPagesPrivilege() { - HANDLE token; - PTOKEN_USER user = NULL; - - if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token) == TRUE) { - DWORD size = 0; - - GetTokenInformation(token, TokenUser, NULL, 0, &size); - if (size) { - user = (PTOKEN_USER) LocalAlloc(LPTR, size); - } - - GetTokenInformation(token, TokenUser, user, size, &size); - CloseHandle(token); - } - - if (!user) { - return FALSE; - } - - LSA_HANDLE handle; - LSA_OBJECT_ATTRIBUTES attributes; - ZeroMemory(&attributes, sizeof(attributes)); - - BOOL result = FALSE; - if (LsaOpenPolicy(NULL, &attributes, POLICY_ALL_ACCESS, &handle) == 0) { - LSA_UNICODE_STRING str = StringToLsaUnicodeString(SE_LOCK_MEMORY_NAME); - - if (LsaAddAccountRights(handle, user->User.Sid, &str, 1) == 0) { - //LOG_NOTICE("Huge pages support was successfully enabled, but reboot required to use it"); - result = TRUE; - } - - LsaClose(handle); - } - - LocalFree(user); - return result; -} - - -static BOOL TrySetLockPagesPrivilege() { - if (SetLockPagesPrivilege()) { - return TRUE; - } - - return ObtainLockPagesPrivilege() && SetLockPagesPrivilege(); -} - - -void Mem::init(bool enabled) -{ - m_enabled = enabled; - - if (enabled && TrySetLockPagesPrivilege()) { - m_flags |= HugepagesAvailable; - } -} - - -void Mem::allocate(MemInfo &info, bool enabled) -{ - info.hugePages = 0; - - if (!enabled) { - info.memory = static_cast(_mm_malloc(info.size, 4096)); - - return; - } - - info.memory = static_cast(VirtualAlloc(nullptr, info.size, MEM_COMMIT | MEM_RESERVE | MEM_LARGE_PAGES, PAGE_READWRITE)); - if (info.memory) { - info.hugePages = info.pages; - - return; - } - - allocate(info, false); -} - - -void Mem::release(MemInfo &info) -{ - if (info.hugePages) { - VirtualFree(info.memory, 0, MEM_RELEASE); - } - else { - _mm_free(info.memory); - } -} - - -void *Mem::allocateExecutableMemory(size_t size) -{ - return VirtualAlloc(0, size, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); -} - - -void Mem::protectExecutableMemory(void *p, size_t size) -{ - DWORD oldProtect; - VirtualProtect(p, size, PAGE_EXECUTE_READ, &oldProtect); -} - - -void Mem::flushInstructionCache(void *p, size_t size) -{ - ::FlushInstructionCache(GetCurrentProcess(), p, size); -} diff --git a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.cpp b/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.cpp deleted file mode 100644 index e9018c98a4..0000000000 --- a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - - -#ifdef _MSC_VER -# include -#else -# include -#endif - -#ifndef bit_AES -# define bit_AES (1 << 25) -#endif - -#ifndef bit_AVX2 -# define bit_AVX2 (1 << 5) -#endif - - -#include "common/cpu/BasicCpuInfo.h" - - -#define VENDOR_ID (0) -#define PROCESSOR_INFO (1) -#define CACHE_TLB_DESCRIPTOR (2) -#define EXTENDED_FEATURES (7) -#define PROCESSOR_BRAND_STRING_1 (0x80000002) -#define PROCESSOR_BRAND_STRING_2 (0x80000003) -#define PROCESSOR_BRAND_STRING_3 (0x80000004) - -#define EAX_Reg (0) -#define EBX_Reg (1) -#define ECX_Reg (2) -#define EDX_Reg (3) - - -#ifdef _MSC_VER -static inline void cpuid(int level, int output[4]) { - __cpuid(output, level); -} -#else -static inline void cpuid(int level, int output[4]) { - int a, b, c, d; - __cpuid_count(level, 0, a, b, c, d); - - output[0] = a; - output[1] = b; - output[2] = c; - output[3] = d; -} -#endif - - -static inline void cpu_brand_string(char* s) { - int32_t cpu_info[4] = { 0 }; - cpuid(VENDOR_ID, cpu_info); - - if (cpu_info[EAX_Reg] >= 4) { - for (int i = 0; i < 4; i++) { - cpuid(0x80000002 + i, cpu_info); - memcpy(s, cpu_info, sizeof(cpu_info)); - s += 16; - } - } -} - - -static inline bool has_aes_ni() -{ - int32_t cpu_info[4] = { 0 }; - cpuid(PROCESSOR_INFO, cpu_info); - - return (cpu_info[ECX_Reg] & bit_AES) != 0; -} - - -static inline bool has_avx2() -{ - int32_t cpu_info[4] = { 0 }; - cpuid(EXTENDED_FEATURES, cpu_info); - - return (cpu_info[EBX_Reg] & bit_AVX2) != 0; -} - - -xmrig::BasicCpuInfo::BasicCpuInfo() : - m_assembly(ASM_NONE), - m_aes(has_aes_ni()), - m_avx2(has_avx2()), - m_brand(), - m_threads(std::thread::hardware_concurrency()) -{ - cpu_brand_string(m_brand); - -# ifndef XMRIG_NO_ASM - if (hasAES()) { - char vendor[13] = { 0 }; - int32_t data[4] = { 0 }; - - cpuid(0, data); - - memcpy(vendor + 0, &data[1], 4); - memcpy(vendor + 4, &data[3], 4); - memcpy(vendor + 8, &data[2], 4); - - if (memcmp(vendor, "GenuineIntel", 12) == 0) { - m_assembly = ASM_INTEL; - } - else if (memcmp(vendor, "AuthenticAMD", 12) == 0) { - m_assembly = ASM_RYZEN; - } - } -# endif -} - - -size_t xmrig::BasicCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const -{ - const size_t count = threads() / 2; - - return count < 1 ? 1 : count; -} diff --git a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.h b/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.h deleted file mode 100644 index 95857ed272..0000000000 --- a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo.h +++ /dev/null @@ -1,73 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_BASICCPUINFO_H -#define XMRIG_BASICCPUINFO_H - - -#include "common/interfaces/ICpuInfo.h" - - -namespace xmrig { - - -class BasicCpuInfo : public ICpuInfo -{ -public: - BasicCpuInfo(); - -protected: - size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const override; - - inline Assembly assembly() const override { return m_assembly; } - inline bool hasAES() const override { return m_aes; } - inline bool hasAVX2() const override { return m_avx2; } - inline bool isSupported() const override { return true; } - inline const char *brand() const override { return m_brand; } - inline int32_t cores() const override { return -1; } - inline int32_t L2() const override { return -1; } - inline int32_t L3() const override { return -1; } - inline int32_t nodes() const override { return -1; } - inline int32_t sockets() const override { return 1; } - inline int32_t threads() const override { return m_threads; } - -# if defined(__x86_64__) || defined(_M_AMD64) || defined (__arm64__) || defined (__aarch64__) - inline bool isX64() const override { return true; } -# else - inline bool isX64() const override { return false; } -# endif - -private: - Assembly m_assembly; - bool m_aes; - bool m_avx2; - char m_brand[64]; - int32_t m_threads; -}; - - -} /* namespace xmrig */ - - -#endif /* XMRIG_BASICCPUINFO_H */ diff --git a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo_arm.cpp b/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo_arm.cpp deleted file mode 100644 index 3396134666..0000000000 --- a/src/Native/libcryptonight/xmrig/common/cpu/BasicCpuInfo_arm.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -#if __ARM_FEATURE_CRYPTO -# include -# include -#endif - - -#include "common/cpu/BasicCpuInfo.h" - - -xmrig::BasicCpuInfo::BasicCpuInfo() : - m_aes(false), - m_avx2(false), - m_brand(), - m_threads(std::thread::hardware_concurrency()) -{ -# ifdef XMRIG_ARMv8 - memcpy(m_brand, "ARMv8", 5); -# else - memcpy(m_brand, "ARMv7", 5); -# endif - -# if __ARM_FEATURE_CRYPTO - m_aes = getauxval(AT_HWCAP) & HWCAP_AES; -# endif -} - - -size_t xmrig::BasicCpuInfo::optimalThreadsCount(size_t memSize, int maxCpuUsage) const -{ - return threads(); -} diff --git a/src/Native/libcryptonight/xmrig/common/cpu/Cpu.cpp b/src/Native/libcryptonight/xmrig/common/cpu/Cpu.cpp deleted file mode 100644 index b1bb28ac73..0000000000 --- a/src/Native/libcryptonight/xmrig/common/cpu/Cpu.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2016-2017 XMRig - * - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include - - -#include "common/cpu/BasicCpuInfo.h" -#include "common/cpu/Cpu.h" - - -static xmrig::ICpuInfo *cpuInfo = nullptr; - - -xmrig::ICpuInfo *xmrig::Cpu::info() -{ - assert(cpuInfo != nullptr); - - return cpuInfo; -} - - -void xmrig::Cpu::init() -{ - assert(cpuInfo == nullptr); - - cpuInfo = new BasicCpuInfo(); -} - - -void xmrig::Cpu::release() -{ - assert(cpuInfo != nullptr); - - delete cpuInfo; - cpuInfo = nullptr; -} diff --git a/src/Native/libcryptonight/xmrig/common/cpu/Cpu.h b/src/Native/libcryptonight/xmrig/common/cpu/Cpu.h deleted file mode 100644 index 1d5a9fb1d1..0000000000 --- a/src/Native/libcryptonight/xmrig/common/cpu/Cpu.h +++ /dev/null @@ -1,46 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CPU_H -#define XMRIG_CPU_H - - -#include "common/interfaces/ICpuInfo.h" - - -namespace xmrig { - - -class Cpu -{ -public: - static ICpuInfo *info(); - static void init(); - static void release(); -}; - - -} /* namespace xmrig */ - - -#endif /* XMRIG_CPU_H */ diff --git a/src/Native/libcryptonight/xmrig/common/crypto/keccak.cpp b/src/Native/libcryptonight/xmrig/common/crypto/keccak.cpp deleted file mode 100644 index 0219ce3668..0000000000 --- a/src/Native/libcryptonight/xmrig/common/crypto/keccak.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include -#include - - -#include "common/crypto/keccak.h" - - -#define HASH_DATA_AREA 136 -#define KECCAK_ROUNDS 24 - -#ifndef ROTL64 -#define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) -#endif - -const uint64_t keccakf_rndc[24] = -{ - 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, - 0x8000000080008000, 0x000000000000808b, 0x0000000080000001, - 0x8000000080008081, 0x8000000000008009, 0x000000000000008a, - 0x0000000000000088, 0x0000000080008009, 0x000000008000000a, - 0x000000008000808b, 0x800000000000008b, 0x8000000000008089, - 0x8000000000008003, 0x8000000000008002, 0x8000000000000080, - 0x000000000000800a, 0x800000008000000a, 0x8000000080008081, - 0x8000000000008080, 0x0000000080000001, 0x8000000080008008 -}; - -// update the state with given number of rounds - -void xmrig::keccakf(uint64_t st[25], int rounds) -{ - int i, j, round; - uint64_t t, bc[5]; - - for (round = 0; round < rounds; ++round) { - - // Theta - bc[0] = st[0] ^ st[5] ^ st[10] ^ st[15] ^ st[20]; - bc[1] = st[1] ^ st[6] ^ st[11] ^ st[16] ^ st[21]; - bc[2] = st[2] ^ st[7] ^ st[12] ^ st[17] ^ st[22]; - bc[3] = st[3] ^ st[8] ^ st[13] ^ st[18] ^ st[23]; - bc[4] = st[4] ^ st[9] ^ st[14] ^ st[19] ^ st[24]; - - for (i = 0; i < 5; ++i) { - t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1); - st[i ] ^= t; - st[i + 5] ^= t; - st[i + 10] ^= t; - st[i + 15] ^= t; - st[i + 20] ^= t; - } - - // Rho Pi - t = st[1]; - st[ 1] = ROTL64(st[ 6], 44); - st[ 6] = ROTL64(st[ 9], 20); - st[ 9] = ROTL64(st[22], 61); - st[22] = ROTL64(st[14], 39); - st[14] = ROTL64(st[20], 18); - st[20] = ROTL64(st[ 2], 62); - st[ 2] = ROTL64(st[12], 43); - st[12] = ROTL64(st[13], 25); - st[13] = ROTL64(st[19], 8); - st[19] = ROTL64(st[23], 56); - st[23] = ROTL64(st[15], 41); - st[15] = ROTL64(st[ 4], 27); - st[ 4] = ROTL64(st[24], 14); - st[24] = ROTL64(st[21], 2); - st[21] = ROTL64(st[ 8], 55); - st[ 8] = ROTL64(st[16], 45); - st[16] = ROTL64(st[ 5], 36); - st[ 5] = ROTL64(st[ 3], 28); - st[ 3] = ROTL64(st[18], 21); - st[18] = ROTL64(st[17], 15); - st[17] = ROTL64(st[11], 10); - st[11] = ROTL64(st[ 7], 6); - st[ 7] = ROTL64(st[10], 3); - st[10] = ROTL64(t, 1); - - // Chi - // unrolled loop, where only last iteration is different - j = 0; - bc[0] = st[j ]; - bc[1] = st[j + 1]; - - st[j ] ^= (~st[j + 1]) & st[j + 2]; - st[j + 1] ^= (~st[j + 2]) & st[j + 3]; - st[j + 2] ^= (~st[j + 3]) & st[j + 4]; - st[j + 3] ^= (~st[j + 4]) & bc[0]; - st[j + 4] ^= (~bc[0]) & bc[1]; - - j = 5; - bc[0] = st[j ]; - bc[1] = st[j + 1]; - - st[j ] ^= (~st[j + 1]) & st[j + 2]; - st[j + 1] ^= (~st[j + 2]) & st[j + 3]; - st[j + 2] ^= (~st[j + 3]) & st[j + 4]; - st[j + 3] ^= (~st[j + 4]) & bc[0]; - st[j + 4] ^= (~bc[0]) & bc[1]; - - j = 10; - bc[0] = st[j ]; - bc[1] = st[j + 1]; - - st[j ] ^= (~st[j + 1]) & st[j + 2]; - st[j + 1] ^= (~st[j + 2]) & st[j + 3]; - st[j + 2] ^= (~st[j + 3]) & st[j + 4]; - st[j + 3] ^= (~st[j + 4]) & bc[0]; - st[j + 4] ^= (~bc[0]) & bc[1]; - - j = 15; - bc[0] = st[j ]; - bc[1] = st[j + 1]; - - st[j ] ^= (~st[j + 1]) & st[j + 2]; - st[j + 1] ^= (~st[j + 2]) & st[j + 3]; - st[j + 2] ^= (~st[j + 3]) & st[j + 4]; - st[j + 3] ^= (~st[j + 4]) & bc[0]; - st[j + 4] ^= (~bc[0]) & bc[1]; - - j = 20; - bc[0] = st[j ]; - bc[1] = st[j + 1]; - bc[2] = st[j + 2]; - bc[3] = st[j + 3]; - bc[4] = st[j + 4]; - - st[j ] ^= (~bc[1]) & bc[2]; - st[j + 1] ^= (~bc[2]) & bc[3]; - st[j + 2] ^= (~bc[3]) & bc[4]; - st[j + 3] ^= (~bc[4]) & bc[0]; - st[j + 4] ^= (~bc[0]) & bc[1]; - - // Iota - st[0] ^= keccakf_rndc[round]; - } -} - -// compute a keccak hash (md) of given byte length from "in" -typedef uint64_t state_t[25]; - - -void xmrig::keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen) -{ - state_t st; - uint8_t temp[144]; - int i, rsiz, rsizw; - - rsiz = sizeof(state_t) == mdlen ? HASH_DATA_AREA : 200 - 2 * mdlen; - rsizw = rsiz / 8; - - memset(st, 0, sizeof(st)); - - for ( ; inlen >= rsiz; inlen -= rsiz, in += rsiz) { - for (i = 0; i < rsizw; i++) { - st[i] ^= ((uint64_t *) in)[i]; - } - - xmrig::keccakf(st, KECCAK_ROUNDS); - } - - // last block and padding - memcpy(temp, in, inlen); - temp[inlen++] = 1; - memset(temp + inlen, 0, rsiz - inlen); - temp[rsiz - 1] |= 0x80; - - for (i = 0; i < rsizw; i++) { - st[i] ^= ((uint64_t *) temp)[i]; - } - - keccakf(st, KECCAK_ROUNDS); - - memcpy(md, st, mdlen); -} diff --git a/src/Native/libcryptonight/xmrig/common/crypto/keccak.h b/src/Native/libcryptonight/xmrig/common/crypto/keccak.h deleted file mode 100644 index 6121044aa7..0000000000 --- a/src/Native/libcryptonight/xmrig/common/crypto/keccak.h +++ /dev/null @@ -1,55 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2011 Markku-Juhani O. Saarinen - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#ifndef XMRIG_KECCAK_H -#define XMRIG_KECCAK_H - -#include -#include - - -namespace xmrig { - -// compute a keccak hash (md) of given byte length from "in" -void keccak(const uint8_t *in, int inlen, uint8_t *md, int mdlen); - - -inline void keccak(const uint8_t *in, size_t inlen, uint8_t *md) -{ - keccak(in, static_cast(inlen), md, 200); -} - - -inline void keccak(const char *in, size_t inlen, uint8_t *md) -{ - keccak(reinterpret_cast(in), static_cast(inlen), md, 200); -} - -// update the state -void keccakf(uint64_t st[25], int norounds); - -} /* namespace xmrig */ - -#endif /* XMRIG_KECCAK_H */ diff --git a/src/Native/libcryptonight/xmrig/common/interfaces/ICpuInfo.h b/src/Native/libcryptonight/xmrig/common/interfaces/ICpuInfo.h deleted file mode 100644 index dd4034b331..0000000000 --- a/src/Native/libcryptonight/xmrig/common/interfaces/ICpuInfo.h +++ /dev/null @@ -1,63 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CPUINFO_H -#define XMRIG_CPUINFO_H - - -#include -#include - - -#include "common/xmrig.h" - - -namespace xmrig { - - -class ICpuInfo -{ -public: - virtual ~ICpuInfo() {} - - virtual bool hasAES() const = 0; - virtual bool hasAVX2() const = 0; - virtual bool isSupported() const = 0; - virtual bool isX64() const = 0; - virtual const char *brand() const = 0; - virtual int32_t cores() const = 0; - virtual int32_t L2() const = 0; - virtual int32_t L3() const = 0; - virtual int32_t nodes() const = 0; - virtual int32_t sockets() const = 0; - virtual int32_t threads() const = 0; - virtual size_t optimalThreadsCount(size_t memSize, int maxCpuUsage) const = 0; - virtual xmrig::Assembly assembly() const = 0; -}; - - -} /* namespace xmrig */ - - -#endif // XMRIG_CPUINFO_H diff --git a/src/Native/libcryptonight/xmrig/common/utils/mm_malloc.h b/src/Native/libcryptonight/xmrig/common/utils/mm_malloc.h deleted file mode 100644 index 30c721a347..0000000000 --- a/src/Native/libcryptonight/xmrig/common/utils/mm_malloc.h +++ /dev/null @@ -1,43 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2016-2018 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef __MM_MALLOC_PORTABLE_H__ -#define __MM_MALLOC_PORTABLE_H__ - - -#ifdef _WIN32 -# ifdef __GNUC__ -# include -# else -# include -# endif -#else -# if defined(XMRIG_ARM) && !defined(__clang__) -# include "aligned_malloc.h" -# else -# include -# endif -#endif - - -#endif /* __MM_MALLOC_PORTABLE_H__ */ diff --git a/src/Native/libcryptonight/xmrig/common/xmrig.h b/src/Native/libcryptonight/xmrig/common/xmrig.h deleted file mode 100644 index e8ca8857e0..0000000000 --- a/src/Native/libcryptonight/xmrig/common/xmrig.h +++ /dev/null @@ -1,121 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_XMRIG_H -#define XMRIG_XMRIG_H - - -namespace xmrig -{ - - -enum Algo { - INVALID_ALGO = -1, - CRYPTONIGHT, /* CryptoNight (2 MB) */ - CRYPTONIGHT_LITE, /* CryptoNight (1 MB) */ - CRYPTONIGHT_HEAVY, /* CryptoNight (4 MB) */ - CRYPTONIGHT_PICO, /* CryptoNight (256 KB) */ - ALGO_MAX -}; - - -//--av=1 For CPUs with hardware AES. -//--av=2 Lower power mode (double hash) of 1. -//--av=3 Software AES implementation. -//--av=4 Lower power mode (double hash) of 3. -enum AlgoVariant { - AV_AUTO, // --av=0 Automatic mode. - AV_SINGLE, // --av=1 Single hash mode - AV_DOUBLE, // --av=2 Double hash mode - AV_SINGLE_SOFT, // --av=3 Single hash mode (Software AES) - AV_DOUBLE_SOFT, // --av=4 Double hash mode (Software AES) - AV_TRIPLE, // --av=5 Triple hash mode - AV_QUAD, // --av=6 Quard hash mode - AV_PENTA, // --av=7 Penta hash mode - AV_TRIPLE_SOFT, // --av=8 Triple hash mode (Software AES) - AV_QUAD_SOFT, // --av=9 Quard hash mode (Software AES) - AV_PENTA_SOFT, // --av=10 Penta hash mode (Software AES) - AV_MAX -}; - - -enum Variant { - VARIANT_AUTO = -1, // Autodetect - VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy - VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7 - VARIANT_TUBE = 2, // Modified CryptoNight-Heavy (TUBE only) - VARIANT_XTL = 3, // Modified CryptoNight variant 1 (Stellite only) - VARIANT_MSR = 4, // Modified CryptoNight variant 1 (Masari only) - VARIANT_XHV = 5, // Modified CryptoNight-Heavy (Haven Protocol only) - VARIANT_XAO = 6, // Modified CryptoNight variant 0 (Alloy only) - VARIANT_RTO = 7, // Modified CryptoNight variant 1 (Arto only) - VARIANT_2 = 8, // CryptoNight variant 2 - VARIANT_HALF = 9, // CryptoNight variant 2 with half iterations (Masari/Stellite) - VARIANT_TRTL = 10, // CryptoNight Turtle (TRTL) - VARIANT_GPU = 11, // CryptoNight-GPU (Ryo) - VARIANT_WOW = 12, // CryptoNightR (Wownero) - VARIANT_4 = 13, // CryptoNightR (Monero's variant 4) - VARIANT_RWZ = 14, // CryptoNight variant 2 with 3/4 iterations and reversed shuffle operation (Graft) - VARIANT_ZLS = 15, // CryptoNight variant 2 with 3/4 iterations (Zelerius) - VARIANT_DOUBLE = 16, // CryptoNight variant 2 with double iterations (X-CASH) - VARIANT_MAX -}; - - -enum AlgoVerify { - VERIFY_HW_AES = 1, - VERIFY_SOFT_AES = 2 -}; - - -enum AesMode { - AES_AUTO, - AES_HW, - AES_SOFT -}; - - -enum OclVendor { - OCL_VENDOR_UNKNOWN = -2, - OCL_VENDOR_MANUAL = -1, - OCL_VENDOR_AMD = 0, - OCL_VENDOR_NVIDIA = 1, - OCL_VENDOR_INTEL = 2 -}; - - -enum Assembly { - ASM_NONE, - ASM_AUTO, - ASM_INTEL, - ASM_RYZEN, - ASM_BULLDOZER, - ASM_MAX -}; - - -} /* namespace xmrig */ - - -#endif /* XMRIG_XMRIG_H */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptoNight.h b/src/Native/libcryptonight/xmrig/crypto/CryptoNight.h deleted file mode 100644 index 91a4c7b71e..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptoNight.h +++ /dev/null @@ -1,63 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2016-2018 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CRYPTONIGHT_H -#define XMRIG_CRYPTONIGHT_H - - -#include -#include - -#if defined _MSC_VER || defined XMRIG_ARM -#define ABI_ATTRIBUTE -#else -#define ABI_ATTRIBUTE __attribute__((ms_abi)) -#endif - -struct cryptonight_ctx; -typedef void(*cn_mainloop_fun_ms_abi)(cryptonight_ctx*) ABI_ATTRIBUTE; -typedef void(*cn_mainloop_double_fun_ms_abi)(cryptonight_ctx*, cryptonight_ctx*) ABI_ATTRIBUTE; - -struct cryptonight_r_data { - int variant; - uint64_t height; - - bool match(const int v, const uint64_t h) const { return (v == variant) && (h == height); } -}; - -struct cryptonight_ctx { - alignas(16) uint8_t state[224]; - alignas(16) uint8_t *memory; - - uint8_t unused[40]; - const uint32_t* saes_table; - - cn_mainloop_fun_ms_abi generated_code; - cn_mainloop_double_fun_ms_abi generated_code_double; - cryptonight_r_data generated_code_data; - cryptonight_r_data generated_code_double_data; -}; - - -#endif /* XMRIG_CRYPTONIGHT_H */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_arm.h b/src/Native/libcryptonight/xmrig/crypto/CryptoNight_arm.h deleted file mode 100644 index d762929c2b..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_arm.h +++ /dev/null @@ -1,844 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2016 Imran Yusuff - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CRYPTONIGHT_ARM_H -#define XMRIG_CRYPTONIGHT_ARM_H - - -#include "common/crypto/keccak.h" -#include "common/utils/mm_malloc.h" -#include "crypto/CryptoNight.h" -#include "crypto/CryptoNight_constants.h" -#include "crypto/CryptoNight_monero.h" -#include "crypto/soft_aes.h" - - -extern "C" -{ -#include "crypto/c_groestl.h" -#include "crypto/c_blake256.h" -#include "crypto/c_jh.h" -#include "crypto/c_skein.h" -} - - -static inline void do_blake_hash(const uint8_t *input, size_t len, uint8_t *output) { - blake256_hash(output, input, len); -} - - -static inline void do_groestl_hash(const uint8_t *input, size_t len, uint8_t *output) { - groestl(input, len * 8, output); -} - - -static inline void do_jh_hash(const uint8_t *input, size_t len, uint8_t *output) { - jh_hash(32 * 8, input, 8 * len, output); -} - - -static inline void do_skein_hash(const uint8_t *input, size_t len, uint8_t *output) { - xmr_skein(input, output); -} - - -void (* const extra_hashes[4])(const uint8_t *, size_t, uint8_t *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash}; - - -static inline __attribute__((always_inline)) __m128i _mm_set_epi64x(const uint64_t a, const uint64_t b) -{ - return vcombine_u64(vcreate_u64(b), vcreate_u64(a)); -} - - -#if __ARM_FEATURE_CRYPTO -static inline __attribute__((always_inline)) __m128i _mm_aesenc_si128(__m128i v, __m128i rkey) -{ - alignas(16) const __m128i zero = { 0 }; - return veorq_u8(vaesmcq_u8(vaeseq_u8(v, zero)), rkey ); -} -#else -static inline __attribute__((always_inline)) __m128i _mm_aesenc_si128(__m128i v, __m128i rkey) -{ - alignas(16) const __m128i zero = { 0 }; - return zero; -} -#endif - - -/* this one was not implemented yet so here it is */ -static inline __attribute__((always_inline)) uint64_t _mm_cvtsi128_si64(__m128i a) -{ - return vgetq_lane_u64(a, 0); -} - - -#if defined (__arm64__) || defined (__aarch64__) -static inline uint64_t __umul128(uint64_t a, uint64_t b, uint64_t* hi) -{ - unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; - *hi = r >> 64; - return (uint64_t) r; -} -#else -static inline uint64_t __umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { - // multiplier = ab = a * 2^32 + b - // multiplicand = cd = c * 2^32 + d - // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d - uint64_t a = multiplier >> 32; - uint64_t b = multiplier & 0xFFFFFFFF; - uint64_t c = multiplicand >> 32; - uint64_t d = multiplicand & 0xFFFFFFFF; - - //uint64_t ac = a * c; - uint64_t ad = a * d; - //uint64_t bc = b * c; - uint64_t bd = b * d; - - uint64_t adbc = ad + (b * c); - uint64_t adbc_carry = adbc < ad ? 1 : 0; - - // multiplier * multiplicand = product_hi * 2^64 + product_lo - uint64_t product_lo = bd + (adbc << 32); - uint64_t product_lo_carry = product_lo < bd ? 1 : 0; - *product_hi = (a * c) + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry; - - return product_lo; -} -#endif - - -// This will shift and xor tmp1 into itself as 4 32-bit vals such as -// sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -static inline __m128i sl_xor(__m128i tmp1) -{ - __m128i tmp4; - tmp4 = _mm_slli_si128(tmp1, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - return tmp1; -} - - -template -static inline void soft_aes_genkey_sub(__m128i* xout0, __m128i* xout2) -{ - __m128i xout1 = soft_aeskeygenassist(*xout2); - xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem - *xout0 = sl_xor(*xout0); - *xout0 = _mm_xor_si128(*xout0, xout1); - xout1 = soft_aeskeygenassist<0x00>(*xout0); - xout1 = _mm_shuffle_epi32(xout1, 0xAA); // see PSHUFD, set all elems to 3rd elem - *xout2 = sl_xor(*xout2); - *xout2 = _mm_xor_si128(*xout2, xout1); -} - - -template -static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) -{ - __m128i xout0 = _mm_load_si128(memory); - __m128i xout2 = _mm_load_si128(memory + 1); - *k0 = xout0; - *k1 = xout2; - - soft_aes_genkey_sub<0x01>(&xout0, &xout2); - *k2 = xout0; - *k3 = xout2; - - soft_aes_genkey_sub<0x02>(&xout0, &xout2); - *k4 = xout0; - *k5 = xout2; - - soft_aes_genkey_sub<0x04>(&xout0, &xout2); - *k6 = xout0; - *k7 = xout2; - - soft_aes_genkey_sub<0x08>(&xout0, &xout2); - *k8 = xout0; - *k9 = xout2; -} - - -template -static inline void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) -{ - if (SOFT_AES) { - *x0 = soft_aesenc((uint32_t*)x0, key); - *x1 = soft_aesenc((uint32_t*)x1, key); - *x2 = soft_aesenc((uint32_t*)x2, key); - *x3 = soft_aesenc((uint32_t*)x3, key); - *x4 = soft_aesenc((uint32_t*)x4, key); - *x5 = soft_aesenc((uint32_t*)x5, key); - *x6 = soft_aesenc((uint32_t*)x6, key); - *x7 = soft_aesenc((uint32_t*)x7, key); - } - else { - *x0 = _mm_aesenc_si128(*x0, key); - *x1 = _mm_aesenc_si128(*x1, key); - *x2 = _mm_aesenc_si128(*x2, key); - *x3 = _mm_aesenc_si128(*x3, key); - *x4 = _mm_aesenc_si128(*x4, key); - *x5 = _mm_aesenc_si128(*x5, key); - *x6 = _mm_aesenc_si128(*x6, key); - *x7 = _mm_aesenc_si128(*x7, key); - } -} - - -inline void mix_and_propagate(__m128i& x0, __m128i& x1, __m128i& x2, __m128i& x3, __m128i& x4, __m128i& x5, __m128i& x6, __m128i& x7) -{ - __m128i tmp0 = x0; - x0 = _mm_xor_si128(x0, x1); - x1 = _mm_xor_si128(x1, x2); - x2 = _mm_xor_si128(x2, x3); - x3 = _mm_xor_si128(x3, x4); - x4 = _mm_xor_si128(x4, x5); - x5 = _mm_xor_si128(x5, x6); - x6 = _mm_xor_si128(x6, x7); - x7 = _mm_xor_si128(x7, tmp0); -} - - -template -static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output) -{ - __m128i xin0, xin1, xin2, xin3, xin4, xin5, xin6, xin7; - __m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - - aes_genkey(input, &k0, &k1, &k2, &k3, &k4, &k5, &k6, &k7, &k8, &k9); - - xin0 = _mm_load_si128(input + 4); - xin1 = _mm_load_si128(input + 5); - xin2 = _mm_load_si128(input + 6); - xin3 = _mm_load_si128(input + 7); - xin4 = _mm_load_si128(input + 8); - xin5 = _mm_load_si128(input + 9); - xin6 = _mm_load_si128(input + 10); - xin7 = _mm_load_si128(input + 11); - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - for (size_t i = 0; i < 16; i++) { - aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k2, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k3, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k4, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k5, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k6, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k7, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k8, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k9, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - - mix_and_propagate(xin0, xin1, xin2, xin3, xin4, xin5, xin6, xin7); - } - } - - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { - aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k2, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k3, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k4, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k5, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k6, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k7, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k8, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k9, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - - _mm_store_si128(output + i + 0, xin0); - _mm_store_si128(output + i + 1, xin1); - _mm_store_si128(output + i + 2, xin2); - _mm_store_si128(output + i + 3, xin3); - _mm_store_si128(output + i + 4, xin4); - _mm_store_si128(output + i + 5, xin5); - _mm_store_si128(output + i + 6, xin6); - _mm_store_si128(output + i + 7, xin7); - } -} - - -#ifndef XMRIG_NO_CN_GPU -template -void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) -{ - constexpr size_t hash_size = 200; // 25x8 bytes - alignas(16) uint64_t hash[25]; - - for (uint64_t i = 0; i < MEM / 512; i++) - { - memcpy(hash, input, hash_size); - hash[0] ^= i; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 160); - output += 160; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 176); - output += 176; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 176); - output += 176; - } -} -#endif - - -template -static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) -{ - __m128i xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7; - __m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - - aes_genkey(output + 2, &k0, &k1, &k2, &k3, &k4, &k5, &k6, &k7, &k8, &k9); - - xout0 = _mm_load_si128(output + 4); - xout1 = _mm_load_si128(output + 5); - xout2 = _mm_load_si128(output + 6); - xout3 = _mm_load_si128(output + 7); - xout4 = _mm_load_si128(output + 8); - xout5 = _mm_load_si128(output + 9); - xout6 = _mm_load_si128(output + 10); - xout7 = _mm_load_si128(output + 11); - - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) - { - xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); - xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); - xout2 = _mm_xor_si128(_mm_load_si128(input + i + 2), xout2); - xout3 = _mm_xor_si128(_mm_load_si128(input + i + 3), xout3); - xout4 = _mm_xor_si128(_mm_load_si128(input + i + 4), xout4); - xout5 = _mm_xor_si128(_mm_load_si128(input + i + 5), xout5); - xout6 = _mm_xor_si128(_mm_load_si128(input + i + 6), xout6); - xout7 = _mm_xor_si128(_mm_load_si128(input + i + 7), xout7); - - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - } - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { - xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); - xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); - xout2 = _mm_xor_si128(_mm_load_si128(input + i + 2), xout2); - xout3 = _mm_xor_si128(_mm_load_si128(input + i + 3), xout3); - xout4 = _mm_xor_si128(_mm_load_si128(input + i + 4), xout4); - xout5 = _mm_xor_si128(_mm_load_si128(input + i + 5), xout5); - xout6 = _mm_xor_si128(_mm_load_si128(input + i + 6), xout6); - xout7 = _mm_xor_si128(_mm_load_si128(input + i + 7), xout7); - - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - - for (size_t i = 0; i < 16; i++) { - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - } - - _mm_store_si128(output + 4, xout0); - _mm_store_si128(output + 5, xout1); - _mm_store_si128(output + 6, xout2); - _mm_store_si128(output + 7, xout3); - _mm_store_si128(output + 8, xout4); - _mm_store_si128(output + 9, xout5); - _mm_store_si128(output + 10, xout6); - _mm_store_si128(output + 11, xout7); -} - - -static inline __m128i aes_round_tweak_div(const __m128i &in, const __m128i &key) -{ - alignas(16) uint32_t k[4]; - alignas(16) uint32_t x[4]; - - _mm_store_si128((__m128i*) k, key); - _mm_store_si128((__m128i*) x, _mm_xor_si128(in, _mm_set_epi64x(0xffffffffffffffff, 0xffffffffffffffff))); - - #define BYTE(p, i) ((unsigned char*)&x[p])[i] - k[0] ^= saes_table[0][BYTE(0, 0)] ^ saes_table[1][BYTE(1, 1)] ^ saes_table[2][BYTE(2, 2)] ^ saes_table[3][BYTE(3, 3)]; - x[0] ^= k[0]; - k[1] ^= saes_table[0][BYTE(1, 0)] ^ saes_table[1][BYTE(2, 1)] ^ saes_table[2][BYTE(3, 2)] ^ saes_table[3][BYTE(0, 3)]; - x[1] ^= k[1]; - k[2] ^= saes_table[0][BYTE(2, 0)] ^ saes_table[1][BYTE(3, 1)] ^ saes_table[2][BYTE(0, 2)] ^ saes_table[3][BYTE(1, 3)]; - x[2] ^= k[2]; - k[3] ^= saes_table[0][BYTE(3, 0)] ^ saes_table[1][BYTE(0, 1)] ^ saes_table[2][BYTE(1, 2)] ^ saes_table[3][BYTE(2, 3)]; - #undef BYTE - - return _mm_load_si128((__m128i*)k); -} - - -template -static inline void cryptonight_monero_tweak(const uint8_t* l, uint64_t idx, __m128i ax0, __m128i bx0, __m128i bx1, __m128i& cx) -{ - uint64_t* mem_out = (uint64_t*)&l[idx]; - - if (BASE == xmrig::VARIANT_2) { - VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - _mm_store_si128((__m128i *)mem_out, _mm_xor_si128(bx0, cx)); - } else { - __m128i tmp = _mm_xor_si128(bx0, cx); - mem_out[0] = _mm_cvtsi128_si64(tmp); - - uint64_t vh = vgetq_lane_u64(tmp, 1); - - uint8_t x = vh >> 24; - static const uint16_t table = 0x7531; - const uint8_t index = (((x >> (VARIANT == xmrig::VARIANT_XTL ? 4 : 3)) & 6) | (x & 1)) << 1; - vh ^= ((table >> index) & 0x3) << 28; - - mem_out[1] = vh; - } -} - - -template -inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 32); - return; - } - - xmrig::keccak(input, size, ctx[0]->state); - - cn_explode_scratchpad((__m128i*) ctx[0]->state, (__m128i*) ctx[0]->memory); - - const uint8_t* l0 = ctx[0]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - - VARIANT1_INIT(0); - VARIANT2_INIT(0); - VARIANT4_RANDOM_MATH_INIT(0); - - uint64_t al0 = h0[0] ^ h0[4]; - uint64_t ah0 = h0[1] ^ h0[5]; - __m128i bx0 = _mm_set_epi64x(h0[3] ^ h0[7], h0[2] ^ h0[6]); - __m128i bx1 = _mm_set_epi64x(h0[9] ^ h0[11], h0[8] ^ h0[10]); - - uint64_t idx0 = al0; - - for (size_t i = 0; i < ITERATIONS; i++) { - __m128i cx; - if (VARIANT == xmrig::VARIANT_TUBE || !SOFT_AES) { - cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]); - } - - const __m128i ax0 = _mm_set_epi64x(ah0, al0); - if (VARIANT == xmrig::VARIANT_TUBE) { - cx = aes_round_tweak_div(cx, ax0); - } - else if (SOFT_AES) { - cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], ax0); - } - else { - cx = _mm_aesenc_si128(cx, ax0); - } - - if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) { - cryptonight_monero_tweak(l0, idx0 & MASK, ax0, bx0, bx1, cx); - } else { - _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); - } - - idx0 = _mm_cvtsi128_si64(cx); - - uint64_t hi, lo, cl, ch; - cl = ((uint64_t*) &l0[idx0 & MASK])[0]; - ch = ((uint64_t*) &l0[idx0 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(0, al0, ah0, cl, bx0, bx1); - if (VARIANT == xmrig::VARIANT_4) { - al0 ^= r0[2] | ((uint64_t)(r0[3]) << 32); - ah0 ^= r0[0] | ((uint64_t)(r0[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(0, cl, cx); - } - } - - lo = __umul128(idx0, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx0, bx1, cx, 0); - } else { - VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al0 += hi; - ah0 += lo; - - ((uint64_t*)&l0[idx0 & MASK])[0] = al0; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0; - } else { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0; - } - - al0 ^= cl; - ah0 ^= ch; - idx0 = al0; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - const int64x2_t x = vld1q_s64(reinterpret_cast(&l0[idx0 & MASK])); - const int64_t n = vgetq_lane_s64(x, 0); - const int32_t d = vgetq_lane_s32(x, 2); - const int64_t q = n / (d | 0x5); - - ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - idx0 = (~d) ^ q; - } - else { - idx0 = d ^ q; - } - } - - if (BASE == xmrig::VARIANT_2) { - bx1 = bx0; - } - - bx0 = cx; - } - - cn_implode_scratchpad((__m128i*) ctx[0]->memory, (__m128i*) ctx[0]->state); - - xmrig::keccakf(h0, 24); - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); -} - - -#ifndef XMRIG_NO_CN_GPU -template -void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad); - - -template -inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::CRYPTONIGHT_GPU_MASK; - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - - static_assert(MASK > 0 && ITERATIONS > 0 && MEM > 0, "unsupported algorithm/variant"); - - xmrig::keccak(input, size, ctx[0]->state); - cn_explode_scratchpad_gpu(ctx[0]->state, ctx[0]->memory); - - fesetround(FE_TONEAREST); - - cn_gpu_inner_arm(ctx[0]->state, ctx[0]->memory); - - cn_implode_scratchpad((__m128i*) ctx[0]->memory, (__m128i*) ctx[0]->state); - - xmrig::keccakf((uint64_t*) ctx[0]->state, 24); - memcpy(output, ctx[0]->state, 32); -} -#endif - - -template -inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 64); - return; - } - - xmrig::keccak(input, size, ctx[0]->state); - xmrig::keccak(input + size, size, ctx[1]->state); - - const uint8_t* l0 = ctx[0]->memory; - const uint8_t* l1 = ctx[1]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - uint64_t* h1 = reinterpret_cast(ctx[1]->state); - - VARIANT1_INIT(0); - VARIANT1_INIT(1); - VARIANT2_INIT(0); - VARIANT2_INIT(1); - VARIANT4_RANDOM_MATH_INIT(0); - VARIANT4_RANDOM_MATH_INIT(1); - - cn_explode_scratchpad((__m128i*) h0, (__m128i*) l0); - cn_explode_scratchpad((__m128i*) h1, (__m128i*) l1); - - uint64_t al0 = h0[0] ^ h0[4]; - uint64_t al1 = h1[0] ^ h1[4]; - uint64_t ah0 = h0[1] ^ h0[5]; - uint64_t ah1 = h1[1] ^ h1[5]; - - __m128i bx00 = _mm_set_epi64x(h0[3] ^ h0[7], h0[2] ^ h0[6]); - __m128i bx01 = _mm_set_epi64x(h0[9] ^ h0[11], h0[8] ^ h0[10]); - __m128i bx10 = _mm_set_epi64x(h1[3] ^ h1[7], h1[2] ^ h1[6]); - __m128i bx11 = _mm_set_epi64x(h1[9] ^ h1[11], h1[8] ^ h1[10]); - - uint64_t idx0 = al0; - uint64_t idx1 = al1; - - for (size_t i = 0; i < ITERATIONS; i++) { - __m128i cx0, cx1; - if (VARIANT == xmrig::VARIANT_TUBE || !SOFT_AES) { - cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]); - cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]); - } - - const __m128i ax0 = _mm_set_epi64x(ah0, al0); - const __m128i ax1 = _mm_set_epi64x(ah1, al1); - if (VARIANT == xmrig::VARIANT_TUBE) { - cx0 = aes_round_tweak_div(cx0, ax0); - cx1 = aes_round_tweak_div(cx1, ax1); - } - else if (SOFT_AES) { - cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], ax0); - cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], ax1); - } - else { - cx0 = _mm_aesenc_si128(cx0, ax0); - cx1 = _mm_aesenc_si128(cx1, ax1); - } - - if (BASE == xmrig::VARIANT_1 || (BASE == xmrig::VARIANT_2)) { - cryptonight_monero_tweak(l0, idx0 & MASK, ax0, bx00, bx01, cx0); - cryptonight_monero_tweak(l1, idx1 & MASK, ax1, bx10, bx11, cx1); - } else { - _mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx00, cx0)); - _mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx10, cx1)); - } - - idx0 = _mm_cvtsi128_si64(cx0); - idx1 = _mm_cvtsi128_si64(cx1); - - uint64_t hi, lo, cl, ch; - cl = ((uint64_t*) &l0[idx0 & MASK])[0]; - ch = ((uint64_t*) &l0[idx0 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(0, al0, ah0, cl, bx00, bx01); - if (VARIANT == xmrig::VARIANT_4) { - al0 ^= r0[2] | ((uint64_t)(r0[3]) << 32); - ah0 ^= r0[0] | ((uint64_t)(r0[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(0, cl, cx0); - } - } - - lo = __umul128(idx0, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx00, bx01, cx0, 0); - } else { - VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al0 += hi; - ah0 += lo; - - ((uint64_t*)&l0[idx0 & MASK])[0] = al0; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0; - } else { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0; - } - - al0 ^= cl; - ah0 ^= ch; - idx0 = al0; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - const int64x2_t x = vld1q_s64(reinterpret_cast(&l0[idx0 & MASK])); - const int64_t n = vgetq_lane_s64(x, 0); - const int32_t d = vgetq_lane_s32(x, 2); - const int64_t q = n / (d | 0x5); - - ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - idx0 = (~d) ^ q; - } - else { - idx0 = d ^ q; - } - } - - cl = ((uint64_t*) &l1[idx1 & MASK])[0]; - ch = ((uint64_t*) &l1[idx1 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(1, al1, ah1, cl, bx10, bx11); - if (VARIANT == xmrig::VARIANT_4) { - al1 ^= r1[2] | ((uint64_t)(r1[3]) << 32); - ah1 ^= r1[0] | ((uint64_t)(r1[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(1, cl, cx1); - } - } - - lo = __umul128(idx1, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l1, idx1 & MASK, ax1, bx10, bx11, cx1, 0); - } else { - VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al1 += hi; - ah1 += lo; - - ((uint64_t*)&l1[idx1 & MASK])[0] = al1; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1; - } else { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1; - } - - al1 ^= cl; - ah1 ^= ch; - idx1 = al1; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - const int64x2_t x = vld1q_s64(reinterpret_cast(&l1[idx1 & MASK])); - const int64_t n = vgetq_lane_s64(x, 0); - const int32_t d = vgetq_lane_s32(x, 2); - const int64_t q = n / (d | 0x5); - - ((int64_t*)&l1[idx1 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - idx1 = (~d) ^ q; - } - else { - idx1 = d ^ q; - } - } - if (BASE == xmrig::VARIANT_2) { - bx01 = bx00; - bx11 = bx10; - } - bx00 = cx0; - bx10 = cx1; - } - - cn_implode_scratchpad((__m128i*) l0, (__m128i*) h0); - cn_implode_scratchpad((__m128i*) l1, (__m128i*) h1); - - xmrig::keccakf(h0, 24); - xmrig::keccakf(h1, 24); - - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); - extra_hashes[ctx[1]->state[0] & 3](ctx[1]->state, 200, output + 32); -} - - -template -inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ -} - - -template -inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ -} - - -template -inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, struct cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ -} - -#endif /* __CRYPTONIGHT_ARM_H__ */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_constants.h b/src/Native/libcryptonight/xmrig/crypto/CryptoNight_constants.h deleted file mode 100644 index b04ce08d41..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_constants.h +++ /dev/null @@ -1,224 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CRYPTONIGHT_CONSTANTS_H -#define XMRIG_CRYPTONIGHT_CONSTANTS_H - - -#include -#include - - -#include "common/xmrig.h" - - -namespace xmrig -{ - -constexpr const size_t CRYPTONIGHT_MEMORY = 2 * 1024 * 1024; -constexpr const uint32_t CRYPTONIGHT_MASK = 0x1FFFF0; -constexpr const uint32_t CRYPTONIGHT_ITER = 0x80000; -constexpr const uint32_t CRYPTONIGHT_HALF_ITER = 0x40000; -constexpr const uint32_t CRYPTONIGHT_XAO_ITER = 0x100000; -constexpr const uint32_t CRYPTONIGHT_DOUBLE_ITER = 0x100000; -constexpr const uint32_t CRYPTONIGHT_WALTZ_ITER = 0x60000; -constexpr const uint32_t CRYPTONIGHT_ZLS_ITER = 0x60000; - -constexpr const uint32_t CRYPTONIGHT_GPU_ITER = 0xC000; -constexpr const uint32_t CRYPTONIGHT_GPU_MASK = 0x1FFFC0; - -constexpr const size_t CRYPTONIGHT_LITE_MEMORY = 1 * 1024 * 1024; -constexpr const uint32_t CRYPTONIGHT_LITE_MASK = 0xFFFF0; -constexpr const uint32_t CRYPTONIGHT_LITE_ITER = 0x40000; - -constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024; -constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0; -constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000; - -constexpr const size_t CRYPTONIGHT_PICO_MEMORY = 256 * 1024; -constexpr const uint32_t CRYPTONIGHT_PICO_MASK = 0x1FFF0; -constexpr const uint32_t CRYPTONIGHT_PICO_ITER = 0x40000; -constexpr const uint32_t CRYPTONIGHT_TRTL_ITER = 0x10000; - - -template inline constexpr size_t cn_select_memory() { return 0; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_MEMORY; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_LITE_MEMORY; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_HEAVY_MEMORY; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_PICO_MEMORY; } - - -inline size_t cn_select_memory(Algo algorithm) -{ - switch(algorithm) - { - case CRYPTONIGHT: - return CRYPTONIGHT_MEMORY; - - case CRYPTONIGHT_LITE: - return CRYPTONIGHT_LITE_MEMORY; - - case CRYPTONIGHT_HEAVY: - return CRYPTONIGHT_HEAVY_MEMORY; - - case CRYPTONIGHT_PICO: - return CRYPTONIGHT_PICO_MEMORY; - - default: - break; - } - - return 0; -} - - -template inline constexpr uint32_t cn_select_mask() { return 0; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_MASK; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_LITE_MASK; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_HEAVY_MASK; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_PICO_MASK; } - - -inline uint32_t cn_select_mask(Algo algorithm) -{ - switch(algorithm) - { - case CRYPTONIGHT: - return CRYPTONIGHT_MASK; - - case CRYPTONIGHT_LITE: - return CRYPTONIGHT_LITE_MASK; - - case CRYPTONIGHT_HEAVY: - return CRYPTONIGHT_HEAVY_MASK; - - case CRYPTONIGHT_PICO: - return CRYPTONIGHT_PICO_MASK; - - default: - break; - } - - return 0; -} - - -template inline constexpr uint32_t cn_select_iter() { return 0; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HALF_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HALF_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_XAO_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_GPU_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_WALTZ_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ZLS_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_DOUBLE_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_TRTL_ITER; } - - -inline uint32_t cn_select_iter(Algo algorithm, Variant variant) -{ - switch (variant) { - case VARIANT_MSR: - case VARIANT_HALF: - return CRYPTONIGHT_HALF_ITER; - - case VARIANT_GPU: - return CRYPTONIGHT_GPU_ITER; - - case VARIANT_RTO: - case VARIANT_DOUBLE: - return CRYPTONIGHT_XAO_ITER; - - case VARIANT_TRTL: - return CRYPTONIGHT_TRTL_ITER; - - case VARIANT_RWZ: - case VARIANT_ZLS: - return CRYPTONIGHT_WALTZ_ITER; - - default: - break; - } - - switch(algorithm) - { - case CRYPTONIGHT: - return CRYPTONIGHT_ITER; - - case CRYPTONIGHT_LITE: - return CRYPTONIGHT_LITE_ITER; - - case CRYPTONIGHT_HEAVY: - return CRYPTONIGHT_HEAVY_ITER; - - case CRYPTONIGHT_PICO: - return CRYPTONIGHT_TRTL_ITER; - - default: - break; - } - - return 0; -} - - -template inline constexpr Variant cn_base_variant() { return VARIANT_0; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_0; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_0; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_0; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_1; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_GPU; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } -template<> inline constexpr Variant cn_base_variant() { return VARIANT_2; } - -template inline constexpr bool cn_is_cryptonight_r() { return false; } -template<> inline constexpr bool cn_is_cryptonight_r() { return true; } -template<> inline constexpr bool cn_is_cryptonight_r() { return true; } - -} /* namespace xmrig */ - - -#endif /* XMRIG_CRYPTONIGHT_CONSTANTS_H */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_monero.h b/src/Native/libcryptonight/xmrig/crypto/CryptoNight_monero.h deleted file mode 100644 index 4e84ac5d09..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_monero.h +++ /dev/null @@ -1,206 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CRYPTONIGHT_MONERO_H -#define XMRIG_CRYPTONIGHT_MONERO_H - -#include -#include - -// VARIANT ALTERATIONS -#ifndef XMRIG_ARM -# define VARIANT1_INIT(part) \ - uint64_t tweak1_2_##part = 0; \ - if (BASE == xmrig::VARIANT_1) { \ - tweak1_2_##part = (*reinterpret_cast(input + 35 + part * size) ^ \ - *(reinterpret_cast(ctx[part]->state) + 24)); \ - } -#else -# define VARIANT1_INIT(part) \ - uint64_t tweak1_2_##part = 0; \ - if (BASE == xmrig::VARIANT_1) { \ - memcpy(&tweak1_2_##part, input + 35 + part * size, sizeof tweak1_2_##part); \ - tweak1_2_##part ^= *(reinterpret_cast(ctx[part]->state) + 24); \ - } -#endif - -#define VARIANT1_1(p) \ - if (BASE == xmrig::VARIANT_1) { \ - const uint8_t tmp = reinterpret_cast(p)[11]; \ - static const uint32_t table = 0x75310; \ - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \ - ((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \ - } - -#define VARIANT1_2(p, part) \ - if (BASE == xmrig::VARIANT_1) { \ - (p) ^= tweak1_2_##part; \ - } - - -#ifndef XMRIG_ARM -# define VARIANT2_INIT(part) \ - __m128i division_result_xmm_##part = _mm_cvtsi64_si128(h##part[12]); \ - __m128i sqrt_result_xmm_##part = _mm_cvtsi64_si128(h##part[13]); - -#ifdef _MSC_VER -# define VARIANT2_SET_ROUNDING_MODE() if (BASE == xmrig::VARIANT_2) { _control87(RC_DOWN, MCW_RC); } -#else -# define VARIANT2_SET_ROUNDING_MODE() if (BASE == xmrig::VARIANT_2) { fesetround(FE_DOWNWARD); } -#endif - -# define VARIANT2_INTEGER_MATH(part, cl, cx) \ - do { \ - const uint64_t sqrt_result = static_cast(_mm_cvtsi128_si64(sqrt_result_xmm_##part)); \ - const uint64_t cx_0 = _mm_cvtsi128_si64(cx); \ - cl ^= static_cast(_mm_cvtsi128_si64(division_result_xmm_##part)) ^ (sqrt_result << 32); \ - const uint32_t d = static_cast(cx_0 + (sqrt_result << 1)) | 0x80000001UL; \ - const uint64_t cx_1 = _mm_cvtsi128_si64(_mm_srli_si128(cx, 8)); \ - const uint64_t division_result = static_cast(cx_1 / d) + ((cx_1 % d) << 32); \ - division_result_xmm_##part = _mm_cvtsi64_si128(static_cast(division_result)); \ - sqrt_result_xmm_##part = int_sqrt_v2(cx_0 + division_result); \ - } while (0) - -# define VARIANT2_SHUFFLE(base_ptr, offset, _a, _b, _b1, _c, reverse) \ - do { \ - const __m128i chunk1 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ (reverse ? 0x30 : 0x10)))); \ - const __m128i chunk2 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20))); \ - const __m128i chunk3 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ (reverse ? 0x10 : 0x30)))); \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10)), _mm_add_epi64(chunk3, _b1)); \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20)), _mm_add_epi64(chunk1, _b)); \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x30)), _mm_add_epi64(chunk2, _a)); \ - if (VARIANT == xmrig::VARIANT_4) { \ - _c = _mm_xor_si128(_mm_xor_si128(_c, chunk3), _mm_xor_si128(chunk1, chunk2)); \ - } \ - } while (0) - -# define VARIANT2_SHUFFLE2(base_ptr, offset, _a, _b, _b1, hi, lo, reverse) \ - do { \ - const __m128i chunk1 = _mm_xor_si128(_mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10))), _mm_set_epi64x(lo, hi)); \ - const __m128i chunk2 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20))); \ - hi ^= ((uint64_t*)((base_ptr) + ((offset) ^ 0x20)))[0]; \ - lo ^= ((uint64_t*)((base_ptr) + ((offset) ^ 0x20)))[1]; \ - const __m128i chunk3 = _mm_load_si128((__m128i *)((base_ptr) + ((offset) ^ 0x30))); \ - if (reverse) { \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10)), _mm_add_epi64(chunk1, _b1)); \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20)), _mm_add_epi64(chunk3, _b)); \ - } else { \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x10)), _mm_add_epi64(chunk3, _b1)); \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x20)), _mm_add_epi64(chunk1, _b)); \ - } \ - _mm_store_si128((__m128i *)((base_ptr) + ((offset) ^ 0x30)), _mm_add_epi64(chunk2, _a)); \ - } while (0) - -#else -# define VARIANT2_INIT(part) \ - uint64_t division_result_##part = h##part[12]; \ - uint64_t sqrt_result_##part = h##part[13]; - -# define VARIANT2_INTEGER_MATH(part, cl, cx) \ - do { \ - const uint64_t cx_0 = _mm_cvtsi128_si64(cx); \ - cl ^= division_result_##part ^ (sqrt_result_##part << 32); \ - const uint32_t d = static_cast(cx_0 + (sqrt_result_##part << 1)) | 0x80000001UL; \ - const uint64_t cx_1 = _mm_cvtsi128_si64(_mm_srli_si128(cx, 8)); \ - division_result_##part = static_cast(cx_1 / d) + ((cx_1 % d) << 32); \ - const uint64_t sqrt_input = cx_0 + division_result_##part; \ - sqrt_result_##part = sqrt(sqrt_input + 18446744073709551616.0) * 2.0 - 8589934592.0; \ - const uint64_t s = sqrt_result_##part >> 1; \ - const uint64_t b = sqrt_result_##part & 1; \ - const uint64_t r2 = (uint64_t)(s) * (s + b) + (sqrt_result_##part << 32); \ - sqrt_result_##part += ((r2 + b > sqrt_input) ? -1 : 0) + ((r2 + (1ULL << 32) < sqrt_input - s) ? 1 : 0); \ - } while (0) - -# define VARIANT2_SHUFFLE(base_ptr, offset, _a, _b, _b1, _c, reverse) \ - do { \ - const uint64x2_t chunk1 = vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ (reverse ? 0x30 : 0x10)))); \ - const uint64x2_t chunk2 = vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x20))); \ - const uint64x2_t chunk3 = vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ (reverse ? 0x10 : 0x30)))); \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x10)), vaddq_u64(chunk3, vreinterpretq_u64_u8(_b1))); \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x20)), vaddq_u64(chunk1, vreinterpretq_u64_u8(_b))); \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x30)), vaddq_u64(chunk2, vreinterpretq_u64_u8(_a))); \ - if (VARIANT == xmrig::VARIANT_4) { \ - _c = veorq_u64(veorq_u64(_c, chunk3), veorq_u64(chunk1, chunk2)); \ - } \ - } while (0) - -# define VARIANT2_SHUFFLE2(base_ptr, offset, _a, _b, _b1, hi, lo, reverse) \ - do { \ - const uint64x2_t chunk1 = veorq_u64(vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x10))), vcombine_u64(vcreate_u64(hi), vcreate_u64(lo))); \ - const uint64x2_t chunk2 = vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x20))); \ - hi ^= ((uint64_t*)((base_ptr) + ((offset) ^ 0x20)))[0]; \ - lo ^= ((uint64_t*)((base_ptr) + ((offset) ^ 0x20)))[1]; \ - const uint64x2_t chunk3 = vld1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x30))); \ - if (reverse) { \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x10)), vaddq_u64(chunk1, vreinterpretq_u64_u8(_b1))); \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x20)), vaddq_u64(chunk3, vreinterpretq_u64_u8(_b))); \ - } else { \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x10)), vaddq_u64(chunk3, vreinterpretq_u64_u8(_b1))); \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x20)), vaddq_u64(chunk1, vreinterpretq_u64_u8(_b))); \ - } \ - vst1q_u64((uint64_t*)((base_ptr) + ((offset) ^ 0x30)), vaddq_u64(chunk2, vreinterpretq_u64_u8(_a))); \ - } while (0) -#endif - -#define SWAP32LE(x) x -#define SWAP64LE(x) x -#define hash_extra_blake(data, length, hash) blake256_hash((uint8_t*)(hash), (uint8_t*)(data), (length)) - -#ifndef NOINLINE -#ifdef __GNUC__ -#define NOINLINE __attribute__ ((noinline)) -#elif _MSC_VER -#define NOINLINE __declspec(noinline) -#else -#define NOINLINE -#endif -#endif - -#include "common/xmrig.h" -#include "variant4_random_math.h" - -#define VARIANT4_RANDOM_MATH_INIT(part) \ - uint32_t r##part[9]; \ - struct V4_Instruction code##part[256]; \ - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { \ - r##part[0] = (uint32_t)(h##part[12]); \ - r##part[1] = (uint32_t)(h##part[12] >> 32); \ - r##part[2] = (uint32_t)(h##part[13]); \ - r##part[3] = (uint32_t)(h##part[13] >> 32); \ - } \ - v4_random_math_init(code##part, height); - -#define VARIANT4_RANDOM_MATH(part, al, ah, cl, bx0, bx1) \ - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { \ - cl ^= (r##part[0] + r##part[1]) | ((uint64_t)(r##part[2] + r##part[3]) << 32); \ - r##part[4] = static_cast(al); \ - r##part[5] = static_cast(ah); \ - r##part[6] = static_cast(_mm_cvtsi128_si32(bx0)); \ - r##part[7] = static_cast(_mm_cvtsi128_si32(bx1)); \ - r##part[8] = static_cast(_mm_cvtsi128_si32(_mm_srli_si128(bx1, 8))); \ - v4_random_math(code##part, r##part); \ - } - -#endif /* XMRIG_CRYPTONIGHT_MONERO_H */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_x86.h b/src/Native/libcryptonight/xmrig/crypto/CryptoNight_x86.h deleted file mode 100644 index 8b9ea7836c..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptoNight_x86.h +++ /dev/null @@ -1,1481 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef XMRIG_CRYPTONIGHT_X86_H -#define XMRIG_CRYPTONIGHT_X86_H - - -#ifdef __GNUC__ -# include -#else -# include -# define __restrict__ __restrict -#endif - - -#include "common/cpu/Cpu.h" -#include "common/crypto/keccak.h" -#include "crypto/CryptoNight.h" -#include "crypto/CryptoNight_constants.h" -#include "crypto/CryptoNight_monero.h" -#include "crypto/soft_aes.h" - - -extern "C" -{ -#include "crypto/c_groestl.h" -#include "crypto/c_blake256.h" -#include "crypto/c_jh.h" -#include "crypto/c_skein.h" -} - - -static inline void do_blake_hash(const uint8_t *input, size_t len, uint8_t *output) { - blake256_hash(output, input, len); -} - - -static inline void do_groestl_hash(const uint8_t *input, size_t len, uint8_t *output) { - groestl(input, len * 8, output); -} - - -static inline void do_jh_hash(const uint8_t *input, size_t len, uint8_t *output) { - jh_hash(32 * 8, input, 8 * len, output); -} - - -static inline void do_skein_hash(const uint8_t *input, size_t len, uint8_t *output) { - xmr_skein(input, output); -} - - -void (* const extra_hashes[4])(const uint8_t *, size_t, uint8_t *) = {do_blake_hash, do_groestl_hash, do_jh_hash, do_skein_hash}; - - -#if defined(__x86_64__) || defined(_M_AMD64) -# ifdef __GNUC__ -static inline uint64_t __umul128(uint64_t a, uint64_t b, uint64_t* hi) -{ - unsigned __int128 r = (unsigned __int128) a * (unsigned __int128) b; - *hi = r >> 64; - return (uint64_t) r; -} -# else - #define __umul128 _umul128 -# endif -#elif defined(__i386__) || defined(_M_IX86) -static inline int64_t _mm_cvtsi128_si64(__m128i a) -{ - return ((uint64_t)(uint32_t)_mm_cvtsi128_si32(a) | ((uint64_t)(uint32_t)_mm_cvtsi128_si32(_mm_srli_si128(a, 4)) << 32)); -} - -static inline __m128i _mm_cvtsi64_si128(int64_t a) { - return _mm_set_epi64x(0, a); -} - -static inline uint64_t __umul128(uint64_t multiplier, uint64_t multiplicand, uint64_t *product_hi) { - // multiplier = ab = a * 2^32 + b - // multiplicand = cd = c * 2^32 + d - // ab * cd = a * c * 2^64 + (a * d + b * c) * 2^32 + b * d - uint64_t a = multiplier >> 32; - uint64_t b = multiplier & 0xFFFFFFFF; - uint64_t c = multiplicand >> 32; - uint64_t d = multiplicand & 0xFFFFFFFF; - - //uint64_t ac = a * c; - uint64_t ad = a * d; - //uint64_t bc = b * c; - uint64_t bd = b * d; - - uint64_t adbc = ad + (b * c); - uint64_t adbc_carry = adbc < ad ? 1 : 0; - - // multiplier * multiplicand = product_hi * 2^64 + product_lo - uint64_t product_lo = bd + (adbc << 32); - uint64_t product_lo_carry = product_lo < bd ? 1 : 0; - *product_hi = (a * c) + (adbc >> 32) + (adbc_carry << 32) + product_lo_carry; - - return product_lo; -} -#endif - - -// This will shift and xor tmp1 into itself as 4 32-bit vals such as -// sl_xor(a1 a2 a3 a4) = a1 (a2^a1) (a3^a2^a1) (a4^a3^a2^a1) -static inline __m128i sl_xor(__m128i tmp1) -{ - __m128i tmp4; - tmp4 = _mm_slli_si128(tmp1, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - tmp4 = _mm_slli_si128(tmp4, 0x04); - tmp1 = _mm_xor_si128(tmp1, tmp4); - return tmp1; -} - - -template -static inline void aes_genkey_sub(__m128i* xout0, __m128i* xout2) -{ - __m128i xout1 = _mm_aeskeygenassist_si128(*xout2, rcon); - xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem - *xout0 = sl_xor(*xout0); - *xout0 = _mm_xor_si128(*xout0, xout1); - xout1 = _mm_aeskeygenassist_si128(*xout0, 0x00); - xout1 = _mm_shuffle_epi32(xout1, 0xAA); // see PSHUFD, set all elems to 3rd elem - *xout2 = sl_xor(*xout2); - *xout2 = _mm_xor_si128(*xout2, xout1); -} - - -template -static inline void soft_aes_genkey_sub(__m128i* xout0, __m128i* xout2) -{ - __m128i xout1 = soft_aeskeygenassist(*xout2); - xout1 = _mm_shuffle_epi32(xout1, 0xFF); // see PSHUFD, set all elems to 4th elem - *xout0 = sl_xor(*xout0); - *xout0 = _mm_xor_si128(*xout0, xout1); - xout1 = soft_aeskeygenassist<0x00>(*xout0); - xout1 = _mm_shuffle_epi32(xout1, 0xAA); // see PSHUFD, set all elems to 3rd elem - *xout2 = sl_xor(*xout2); - *xout2 = _mm_xor_si128(*xout2, xout1); -} - - -template -static inline void aes_genkey(const __m128i* memory, __m128i* k0, __m128i* k1, __m128i* k2, __m128i* k3, __m128i* k4, __m128i* k5, __m128i* k6, __m128i* k7, __m128i* k8, __m128i* k9) -{ - __m128i xout0 = _mm_load_si128(memory); - __m128i xout2 = _mm_load_si128(memory + 1); - *k0 = xout0; - *k1 = xout2; - - SOFT_AES ? soft_aes_genkey_sub<0x01>(&xout0, &xout2) : aes_genkey_sub<0x01>(&xout0, &xout2); - *k2 = xout0; - *k3 = xout2; - - SOFT_AES ? soft_aes_genkey_sub<0x02>(&xout0, &xout2) : aes_genkey_sub<0x02>(&xout0, &xout2); - *k4 = xout0; - *k5 = xout2; - - SOFT_AES ? soft_aes_genkey_sub<0x04>(&xout0, &xout2) : aes_genkey_sub<0x04>(&xout0, &xout2); - *k6 = xout0; - *k7 = xout2; - - SOFT_AES ? soft_aes_genkey_sub<0x08>(&xout0, &xout2) : aes_genkey_sub<0x08>(&xout0, &xout2); - *k8 = xout0; - *k9 = xout2; -} - - -static FORCEINLINE void soft_aesenc(void* __restrict ptr, const void* __restrict key, const uint32_t* __restrict t) -{ - uint32_t x0 = ((const uint32_t*)(ptr))[0]; - uint32_t x1 = ((const uint32_t*)(ptr))[1]; - uint32_t x2 = ((const uint32_t*)(ptr))[2]; - uint32_t x3 = ((const uint32_t*)(ptr))[3]; - - uint32_t y0 = t[x0 & 0xff]; x0 >>= 8; - uint32_t y1 = t[x1 & 0xff]; x1 >>= 8; - uint32_t y2 = t[x2 & 0xff]; x2 >>= 8; - uint32_t y3 = t[x3 & 0xff]; x3 >>= 8; - t += 256; - - y0 ^= t[x1 & 0xff]; x1 >>= 8; - y1 ^= t[x2 & 0xff]; x2 >>= 8; - y2 ^= t[x3 & 0xff]; x3 >>= 8; - y3 ^= t[x0 & 0xff]; x0 >>= 8; - t += 256; - - y0 ^= t[x2 & 0xff]; x2 >>= 8; - y1 ^= t[x3 & 0xff]; x3 >>= 8; - y2 ^= t[x0 & 0xff]; x0 >>= 8; - y3 ^= t[x1 & 0xff]; x1 >>= 8; - t += 256; - - y0 ^= t[x3]; - y1 ^= t[x0]; - y2 ^= t[x1]; - y3 ^= t[x2]; - - ((uint32_t*)ptr)[0] = y0 ^ ((uint32_t*)key)[0]; - ((uint32_t*)ptr)[1] = y1 ^ ((uint32_t*)key)[1]; - ((uint32_t*)ptr)[2] = y2 ^ ((uint32_t*)key)[2]; - ((uint32_t*)ptr)[3] = y3 ^ ((uint32_t*)key)[3]; -} - -static FORCEINLINE __m128i soft_aesenc(const void* __restrict ptr, const __m128i key, const uint32_t* __restrict t) -{ - uint32_t x0 = ((const uint32_t*)(ptr))[0]; - uint32_t x1 = ((const uint32_t*)(ptr))[1]; - uint32_t x2 = ((const uint32_t*)(ptr))[2]; - uint32_t x3 = ((const uint32_t*)(ptr))[3]; - - uint32_t y0 = t[x0 & 0xff]; x0 >>= 8; - uint32_t y1 = t[x1 & 0xff]; x1 >>= 8; - uint32_t y2 = t[x2 & 0xff]; x2 >>= 8; - uint32_t y3 = t[x3 & 0xff]; x3 >>= 8; - t += 256; - - y0 ^= t[x1 & 0xff]; x1 >>= 8; - y1 ^= t[x2 & 0xff]; x2 >>= 8; - y2 ^= t[x3 & 0xff]; x3 >>= 8; - y3 ^= t[x0 & 0xff]; x0 >>= 8; - t += 256; - - y0 ^= t[x2 & 0xff]; x2 >>= 8; - y1 ^= t[x3 & 0xff]; x3 >>= 8; - y2 ^= t[x0 & 0xff]; x0 >>= 8; - y3 ^= t[x1 & 0xff]; x1 >>= 8; - - y0 ^= t[x3 + 256]; - y1 ^= t[x0 + 256]; - y2 ^= t[x1 + 256]; - y3 ^= t[x2 + 256]; - - return _mm_xor_si128(_mm_set_epi32(y3, y2, y1, y0), key); -} - -template -void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7); - -template<> -NOINLINE void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) -{ - *x0 = soft_aesenc((uint32_t*)x0, key, (const uint32_t*)saes_table); - *x1 = soft_aesenc((uint32_t*)x1, key, (const uint32_t*)saes_table); - *x2 = soft_aesenc((uint32_t*)x2, key, (const uint32_t*)saes_table); - *x3 = soft_aesenc((uint32_t*)x3, key, (const uint32_t*)saes_table); - *x4 = soft_aesenc((uint32_t*)x4, key, (const uint32_t*)saes_table); - *x5 = soft_aesenc((uint32_t*)x5, key, (const uint32_t*)saes_table); - *x6 = soft_aesenc((uint32_t*)x6, key, (const uint32_t*)saes_table); - *x7 = soft_aesenc((uint32_t*)x7, key, (const uint32_t*)saes_table); -} - -template<> -FORCEINLINE void aes_round(__m128i key, __m128i* x0, __m128i* x1, __m128i* x2, __m128i* x3, __m128i* x4, __m128i* x5, __m128i* x6, __m128i* x7) -{ - *x0 = _mm_aesenc_si128(*x0, key); - *x1 = _mm_aesenc_si128(*x1, key); - *x2 = _mm_aesenc_si128(*x2, key); - *x3 = _mm_aesenc_si128(*x3, key); - *x4 = _mm_aesenc_si128(*x4, key); - *x5 = _mm_aesenc_si128(*x5, key); - *x6 = _mm_aesenc_si128(*x6, key); - *x7 = _mm_aesenc_si128(*x7, key); -} - -inline void mix_and_propagate(__m128i& x0, __m128i& x1, __m128i& x2, __m128i& x3, __m128i& x4, __m128i& x5, __m128i& x6, __m128i& x7) -{ - __m128i tmp0 = x0; - x0 = _mm_xor_si128(x0, x1); - x1 = _mm_xor_si128(x1, x2); - x2 = _mm_xor_si128(x2, x3); - x3 = _mm_xor_si128(x3, x4); - x4 = _mm_xor_si128(x4, x5); - x5 = _mm_xor_si128(x5, x6); - x6 = _mm_xor_si128(x6, x7); - x7 = _mm_xor_si128(x7, tmp0); -} - - -template -static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output) -{ - __m128i xin0, xin1, xin2, xin3, xin4, xin5, xin6, xin7; - __m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - - aes_genkey(input, &k0, &k1, &k2, &k3, &k4, &k5, &k6, &k7, &k8, &k9); - - xin0 = _mm_load_si128(input + 4); - xin1 = _mm_load_si128(input + 5); - xin2 = _mm_load_si128(input + 6); - xin3 = _mm_load_si128(input + 7); - xin4 = _mm_load_si128(input + 8); - xin5 = _mm_load_si128(input + 9); - xin6 = _mm_load_si128(input + 10); - xin7 = _mm_load_si128(input + 11); - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - for (size_t i = 0; i < 16; i++) { - aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k2, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k3, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k4, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k5, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k6, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k7, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k8, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k9, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - - mix_and_propagate(xin0, xin1, xin2, xin3, xin4, xin5, xin6, xin7); - } - } - - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { - aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k2, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k3, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k4, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k5, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k6, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k7, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k8, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - aes_round(k9, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); - - _mm_store_si128(output + i + 0, xin0); - _mm_store_si128(output + i + 1, xin1); - _mm_store_si128(output + i + 2, xin2); - _mm_store_si128(output + i + 3, xin3); - _mm_store_si128(output + i + 4, xin4); - _mm_store_si128(output + i + 5, xin5); - _mm_store_si128(output + i + 6, xin6); - _mm_store_si128(output + i + 7, xin7); - } -} - - -#ifndef XMRIG_NO_CN_GPU -template -void cn_explode_scratchpad_gpu(const uint8_t *input, uint8_t *output) -{ - constexpr size_t hash_size = 200; // 25x8 bytes - alignas(16) uint64_t hash[25]; - - for (uint64_t i = 0; i < MEM / 512; i++) - { - memcpy(hash, input, hash_size); - hash[0] ^= i; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 160); - output += 160; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 176); - output += 176; - - xmrig::keccakf(hash, 24); - memcpy(output, hash, 176); - output += 176; - } -} -#endif - - -template -static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) -{ - __m128i xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7; - __m128i k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - - aes_genkey(output + 2, &k0, &k1, &k2, &k3, &k4, &k5, &k6, &k7, &k8, &k9); - - xout0 = _mm_load_si128(output + 4); - xout1 = _mm_load_si128(output + 5); - xout2 = _mm_load_si128(output + 6); - xout3 = _mm_load_si128(output + 7); - xout4 = _mm_load_si128(output + 8); - xout5 = _mm_load_si128(output + 9); - xout6 = _mm_load_si128(output + 10); - xout7 = _mm_load_si128(output + 11); - - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) - { - xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); - xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); - xout2 = _mm_xor_si128(_mm_load_si128(input + i + 2), xout2); - xout3 = _mm_xor_si128(_mm_load_si128(input + i + 3), xout3); - xout4 = _mm_xor_si128(_mm_load_si128(input + i + 4), xout4); - xout5 = _mm_xor_si128(_mm_load_si128(input + i + 5), xout5); - xout6 = _mm_xor_si128(_mm_load_si128(input + i + 6), xout6); - xout7 = _mm_xor_si128(_mm_load_si128(input + i + 7), xout7); - - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - } - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { - xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); - xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); - xout2 = _mm_xor_si128(_mm_load_si128(input + i + 2), xout2); - xout3 = _mm_xor_si128(_mm_load_si128(input + i + 3), xout3); - xout4 = _mm_xor_si128(_mm_load_si128(input + i + 4), xout4); - xout5 = _mm_xor_si128(_mm_load_si128(input + i + 5), xout5); - xout6 = _mm_xor_si128(_mm_load_si128(input + i + 6), xout6); - xout7 = _mm_xor_si128(_mm_load_si128(input + i + 7), xout7); - - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - - for (size_t i = 0; i < 16; i++) { - aes_round(k0, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k1, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k2, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k3, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k4, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k5, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k6, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k7, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - - mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); - } - } - - _mm_store_si128(output + 4, xout0); - _mm_store_si128(output + 5, xout1); - _mm_store_si128(output + 6, xout2); - _mm_store_si128(output + 7, xout3); - _mm_store_si128(output + 8, xout4); - _mm_store_si128(output + 9, xout5); - _mm_store_si128(output + 10, xout6); - _mm_store_si128(output + 11, xout7); -} - - -static inline __m128i aes_round_tweak_div(const __m128i &in, const __m128i &key) -{ - alignas(16) uint32_t k[4]; - alignas(16) uint32_t x[4]; - - _mm_store_si128((__m128i*) k, key); - _mm_store_si128((__m128i*) x, _mm_xor_si128(in, _mm_set_epi64x(0xffffffffffffffff, 0xffffffffffffffff))); - - #define BYTE(p, i) ((unsigned char*)&x[p])[i] - k[0] ^= saes_table[0][BYTE(0, 0)] ^ saes_table[1][BYTE(1, 1)] ^ saes_table[2][BYTE(2, 2)] ^ saes_table[3][BYTE(3, 3)]; - x[0] ^= k[0]; - k[1] ^= saes_table[0][BYTE(1, 0)] ^ saes_table[1][BYTE(2, 1)] ^ saes_table[2][BYTE(3, 2)] ^ saes_table[3][BYTE(0, 3)]; - x[1] ^= k[1]; - k[2] ^= saes_table[0][BYTE(2, 0)] ^ saes_table[1][BYTE(3, 1)] ^ saes_table[2][BYTE(0, 2)] ^ saes_table[3][BYTE(1, 3)]; - x[2] ^= k[2]; - k[3] ^= saes_table[0][BYTE(3, 0)] ^ saes_table[1][BYTE(0, 1)] ^ saes_table[2][BYTE(1, 2)] ^ saes_table[3][BYTE(2, 3)]; - #undef BYTE - - return _mm_load_si128((__m128i*)k); -} - - -static inline __m128i int_sqrt_v2(const uint64_t n0) -{ - __m128d x = _mm_castsi128_pd(_mm_add_epi64(_mm_cvtsi64_si128(n0 >> 12), _mm_set_epi64x(0, 1023ULL << 52))); - x = _mm_sqrt_sd(_mm_setzero_pd(), x); - uint64_t r = static_cast(_mm_cvtsi128_si64(_mm_castpd_si128(x))); - - const uint64_t s = r >> 20; - r >>= 19; - - uint64_t x2 = (s - (1022ULL << 32)) * (r - s - (1022ULL << 32) + 1); -# if (defined(_MSC_VER) || __GNUC__ > 7 || (__GNUC__ == 7 && __GNUC_MINOR__ > 1)) && (defined(__x86_64__) || defined(_M_AMD64)) - _addcarry_u64(_subborrow_u64(0, x2, n0, (unsigned long long int*)&x2), r, 0, (unsigned long long int*)&r); -# else - if (x2 < n0) ++r; -# endif - - return _mm_cvtsi64_si128(r); -} - - -template -static inline void cryptonight_monero_tweak(uint64_t* mem_out, const uint8_t* l, uint64_t idx, __m128i ax0, __m128i bx0, __m128i bx1, __m128i& cx) -{ - if (BASE == xmrig::VARIANT_2) { - VARIANT2_SHUFFLE(l, idx, ax0, bx0, bx1, cx, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - _mm_store_si128((__m128i *)mem_out, _mm_xor_si128(bx0, cx)); - } else { - __m128i tmp = _mm_xor_si128(bx0, cx); - mem_out[0] = _mm_cvtsi128_si64(tmp); - - tmp = _mm_castps_si128(_mm_movehl_ps(_mm_castsi128_ps(tmp), _mm_castsi128_ps(tmp))); - uint64_t vh = _mm_cvtsi128_si64(tmp); - - uint8_t x = static_cast(vh >> 24); - static const uint16_t table = 0x7531; - const uint8_t index = (((x >> (VARIANT == xmrig::VARIANT_XTL ? 4 : 3)) & 6) | (x & 1)) << 1; - vh ^= ((table >> index) & 0x3) << 28; - - mem_out[1] = vh; - } -} - -void wow_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); -void v4_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); - -template -inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - static_assert(MASK > 0 && ITERATIONS > 0 && MEM > 0, "unsupported algorithm/variant"); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 32); - return; - } - - xmrig::keccak(input, size, ctx[0]->state); - - cn_explode_scratchpad((__m128i*) ctx[0]->state, (__m128i*) ctx[0]->memory); - - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - -#ifndef XMRIG_NO_ASM - if (SOFT_AES && xmrig::cn_is_cryptonight_r()) - { - if (!ctx[0]->generated_code_data.match(VARIANT, height)) { - V4_Instruction code[256]; - const int code_size = v4_random_math_init(code, height); - - if (VARIANT == xmrig::VARIANT_WOW) - wow_soft_aes_compile_code(code, code_size, reinterpret_cast(ctx[0]->generated_code), xmrig::ASM_NONE); - else if (VARIANT == xmrig::VARIANT_4) - v4_soft_aes_compile_code(code, code_size, reinterpret_cast(ctx[0]->generated_code), xmrig::ASM_NONE); - - ctx[0]->generated_code_data.variant = VARIANT; - ctx[0]->generated_code_data.height = height; - } - - ctx[0]->saes_table = (const uint32_t*)saes_table; - ctx[0]->generated_code(ctx[0]); - } else { -#endif - - const uint8_t* l0 = ctx[0]->memory; - - VARIANT1_INIT(0); - VARIANT2_INIT(0); - VARIANT2_SET_ROUNDING_MODE(); - VARIANT4_RANDOM_MATH_INIT(0); - - uint64_t al0 = h0[0] ^ h0[4]; - uint64_t ah0 = h0[1] ^ h0[5]; - __m128i bx0 = _mm_set_epi64x(h0[3] ^ h0[7], h0[2] ^ h0[6]); - __m128i bx1 = _mm_set_epi64x(h0[9] ^ h0[11], h0[8] ^ h0[10]); - - uint64_t idx0 = al0; - - for (size_t i = 0; i < ITERATIONS; i++) { - __m128i cx; - if (VARIANT == xmrig::VARIANT_TUBE || !SOFT_AES) { - cx = _mm_load_si128((__m128i *) &l0[idx0 & MASK]); - } - - const __m128i ax0 = _mm_set_epi64x(ah0, al0); - if (VARIANT == xmrig::VARIANT_TUBE) { - cx = aes_round_tweak_div(cx, ax0); - } - else if (SOFT_AES) { - cx = soft_aesenc((uint32_t*)&l0[idx0 & MASK], ax0, (const uint32_t*)saes_table); - } - else { - cx = _mm_aesenc_si128(cx, ax0); - } - - if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx0, bx1, cx); - } else { - _mm_store_si128((__m128i *)&l0[idx0 & MASK], _mm_xor_si128(bx0, cx)); - } - - idx0 = _mm_cvtsi128_si64(cx); - - uint64_t hi, lo, cl, ch; - cl = ((uint64_t*) &l0[idx0 & MASK])[0]; - ch = ((uint64_t*) &l0[idx0 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(0, al0, ah0, cl, bx0, bx1); - if (VARIANT == xmrig::VARIANT_4) { - al0 ^= r0[2] | ((uint64_t)(r0[3]) << 32); - ah0 ^= r0[0] | ((uint64_t)(r0[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(0, cl, cx); - } - } - - lo = __umul128(idx0, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx0, bx1, cx, 0); - } else { - VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx0, bx1, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al0 += hi; - ah0 += lo; - - ((uint64_t*)&l0[idx0 & MASK])[0] = al0; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0; - } else { - ((uint64_t*)&l0[idx0 & MASK])[1] = ah0; - } - - al0 ^= cl; - ah0 ^= ch; - idx0 = al0; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - int64_t n = ((int64_t*)&l0[idx0 & MASK])[0]; - int32_t d = ((int32_t*)&l0[idx0 & MASK])[2]; - int64_t q = n / (d | 0x5); - - ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - d = ~d; - } - - idx0 = d ^ q; - } - - if (BASE == xmrig::VARIANT_2) { - bx1 = bx0; - } - - bx0 = cx; - } - -#ifndef XMRIG_NO_ASM - } -#endif - - cn_implode_scratchpad((__m128i*) ctx[0]->memory, (__m128i*) ctx[0]->state); - - xmrig::keccakf(h0, 24); - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); -} - - -#ifndef XMRIG_NO_CN_GPU -template -void cn_gpu_inner_avx(const uint8_t *spad, uint8_t *lpad); - - -template -void cn_gpu_inner_ssse3(const uint8_t *spad, uint8_t *lpad); - - -template -inline void cryptonight_single_hash_gpu(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::CRYPTONIGHT_GPU_MASK; - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - - static_assert(MASK > 0 && ITERATIONS > 0 && MEM > 0, "unsupported algorithm/variant"); - - xmrig::keccak(input, size, ctx[0]->state); - cn_explode_scratchpad_gpu(ctx[0]->state, ctx[0]->memory); - -# ifdef _MSC_VER - _control87(RC_NEAR, MCW_RC); -# else - fesetround(FE_TONEAREST); -# endif - - if (xmrig::Cpu::info()->hasAVX2()) { - cn_gpu_inner_avx(ctx[0]->state, ctx[0]->memory); - } else { - cn_gpu_inner_ssse3(ctx[0]->state, ctx[0]->memory); - } - - cn_implode_scratchpad((__m128i*) ctx[0]->memory, (__m128i*) ctx[0]->state); - - xmrig::keccakf((uint64_t*) ctx[0]->state, 24); - memcpy(output, ctx[0]->state, 32); -} -#endif - - -#ifndef XMRIG_NO_ASM -extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx* ctx0, cryptonight_ctx* ctx1); -extern "C" void cnv2_rwz_mainloop_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_rwz_double_mainloop_asm(cryptonight_ctx* ctx0, cryptonight_ctx* ctx1); - -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm; -extern xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm; - -extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ivybridge_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ryzen_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm; -extern xmrig::CpuThread::cn_mainloop_double_fun cn_trtl_double_mainloop_sandybridge_asm; - -extern xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_ivybridge_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_ryzen_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_bulldozer_asm; -extern xmrig::CpuThread::cn_mainloop_double_fun cn_zls_double_mainloop_sandybridge_asm; - -extern xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_ivybridge_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_ryzen_asm; -extern xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_bulldozer_asm; -extern xmrig::CpuThread::cn_mainloop_double_fun cn_double_double_mainloop_sandybridge_asm; - -void wow_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); -void v4_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); -void wow_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); -void v4_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM); - -template -void cn_r_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - v4_compile_code(code, code_size, machine_code, ASM); -} - -template -void cn_r_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - v4_compile_code_double(code, code_size, machine_code, ASM); -} - -template<> -void cn_r_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - wow_compile_code(code, code_size, machine_code, ASM); -} - -template<> -void cn_r_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - wow_compile_code_double(code, code_size, machine_code, ASM); -} - -template -inline void cryptonight_single_hash_asm(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MEM = xmrig::cn_select_memory(); - - if (xmrig::cn_is_cryptonight_r() && !ctx[0]->generated_code_data.match(VARIANT, height)) { - V4_Instruction code[256]; - const int code_size = v4_random_math_init(code, height); - cn_r_compile_code(code, code_size, reinterpret_cast(ctx[0]->generated_code), ASM); - ctx[0]->generated_code_data.variant = VARIANT; - ctx[0]->generated_code_data.height = height; - } - - xmrig::keccak(input, size, ctx[0]->state); - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory)); - - if (VARIANT == xmrig::VARIANT_2) { - if (ASM == xmrig::ASM_INTEL) { - cnv2_mainloop_ivybridge_asm(ctx[0]); - } - else if (ASM == xmrig::ASM_RYZEN) { - cnv2_mainloop_ryzen_asm(ctx[0]); - } - else { - cnv2_mainloop_bulldozer_asm(ctx[0]); - } - } - else if (VARIANT == xmrig::VARIANT_HALF) { - if (ASM == xmrig::ASM_INTEL) { - cn_half_mainloop_ivybridge_asm(ctx[0]); - } - else if (ASM == xmrig::ASM_RYZEN) { - cn_half_mainloop_ryzen_asm(ctx[0]); - } - else { - cn_half_mainloop_bulldozer_asm(ctx[0]); - } - } - else if (VARIANT == xmrig::VARIANT_TRTL) { - if (ASM == xmrig::ASM_INTEL) { - cn_trtl_mainloop_ivybridge_asm(ctx[0]); - } - else if (ASM == xmrig::ASM_RYZEN) { - cn_trtl_mainloop_ryzen_asm(ctx[0]); - } - else { - cn_trtl_mainloop_bulldozer_asm(ctx[0]); - } - } - else if (VARIANT == xmrig::VARIANT_RWZ) { - cnv2_rwz_mainloop_asm(ctx[0]); - } - else if (VARIANT == xmrig::VARIANT_ZLS) { - if (ASM == xmrig::ASM_INTEL) { - cn_zls_mainloop_ivybridge_asm(ctx[0]); - } - else if (ASM == xmrig::ASM_RYZEN) { - cn_zls_mainloop_ryzen_asm(ctx[0]); - } - else { - cn_zls_mainloop_bulldozer_asm(ctx[0]); - } - } - else if (VARIANT == xmrig::VARIANT_DOUBLE) { - if (ASM == xmrig::ASM_INTEL) { - cn_double_mainloop_ivybridge_asm(ctx[0]); - } - else if (ASM == xmrig::ASM_RYZEN) { - cn_double_mainloop_ryzen_asm(ctx[0]); - } - else { - cn_double_mainloop_bulldozer_asm(ctx[0]); - } - } - else if (xmrig::cn_is_cryptonight_r()) { - ctx[0]->generated_code(ctx[0]); - } - - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state)); - xmrig::keccakf(reinterpret_cast(ctx[0]->state), 24); - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); -} - - -template -inline void cryptonight_double_hash_asm(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MEM = xmrig::cn_select_memory(); - - if (xmrig::cn_is_cryptonight_r() && !ctx[0]->generated_code_double_data.match(VARIANT, height)) { - V4_Instruction code[256]; - const int code_size = v4_random_math_init(code, height); - cn_r_compile_code_double(code, code_size, reinterpret_cast(ctx[0]->generated_code_double), ASM); - ctx[0]->generated_code_double_data.variant = VARIANT; - ctx[0]->generated_code_double_data.height = height; - } - - xmrig::keccak(input, size, ctx[0]->state); - xmrig::keccak(input + size, size, ctx[1]->state); - - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->state), reinterpret_cast<__m128i*>(ctx[0]->memory)); - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[1]->state), reinterpret_cast<__m128i*>(ctx[1]->memory)); - - if (VARIANT == xmrig::VARIANT_2) { - cnv2_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); - } - else if (VARIANT == xmrig::VARIANT_HALF) { - cn_half_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); - } - else if (VARIANT == xmrig::VARIANT_TRTL) { - cn_trtl_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); - } - else if (VARIANT == xmrig::VARIANT_RWZ) { - cnv2_rwz_double_mainloop_asm(ctx[0], ctx[1]); - } - else if (VARIANT == xmrig::VARIANT_ZLS) { - cn_zls_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); - } - else if (VARIANT == xmrig::VARIANT_DOUBLE) { - cn_double_double_mainloop_sandybridge_asm(ctx[0], ctx[1]); - } - else if (xmrig::cn_is_cryptonight_r()) { - ctx[0]->generated_code_double(ctx[0], ctx[1]); - } - - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[0]->memory), reinterpret_cast<__m128i*>(ctx[0]->state)); - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[1]->memory), reinterpret_cast<__m128i*>(ctx[1]->state)); - - xmrig::keccakf(reinterpret_cast(ctx[0]->state), 24); - xmrig::keccakf(reinterpret_cast(ctx[1]->state), 24); - - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); - extra_hashes[ctx[1]->state[0] & 3](ctx[1]->state, 200, output + 32); -} -#endif - - -template -inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 64); - return; - } - - xmrig::keccak(input, size, ctx[0]->state); - xmrig::keccak(input + size, size, ctx[1]->state); - - const uint8_t* l0 = ctx[0]->memory; - const uint8_t* l1 = ctx[1]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - uint64_t* h1 = reinterpret_cast(ctx[1]->state); - - VARIANT1_INIT(0); - VARIANT1_INIT(1); - VARIANT2_INIT(0); - VARIANT2_INIT(1); - VARIANT2_SET_ROUNDING_MODE(); - VARIANT4_RANDOM_MATH_INIT(0); - VARIANT4_RANDOM_MATH_INIT(1); - - cn_explode_scratchpad((__m128i*) h0, (__m128i*) l0); - cn_explode_scratchpad((__m128i*) h1, (__m128i*) l1); - - uint64_t al0 = h0[0] ^ h0[4]; - uint64_t al1 = h1[0] ^ h1[4]; - uint64_t ah0 = h0[1] ^ h0[5]; - uint64_t ah1 = h1[1] ^ h1[5]; - - __m128i bx00 = _mm_set_epi64x(h0[3] ^ h0[7], h0[2] ^ h0[6]); - __m128i bx01 = _mm_set_epi64x(h0[9] ^ h0[11], h0[8] ^ h0[10]); - __m128i bx10 = _mm_set_epi64x(h1[3] ^ h1[7], h1[2] ^ h1[6]); - __m128i bx11 = _mm_set_epi64x(h1[9] ^ h1[11], h1[8] ^ h1[10]); - - uint64_t idx0 = al0; - uint64_t idx1 = al1; - - for (size_t i = 0; i < ITERATIONS; i++) { - __m128i cx0, cx1; - if (VARIANT == xmrig::VARIANT_TUBE || !SOFT_AES) { - cx0 = _mm_load_si128((__m128i *) &l0[idx0 & MASK]); - cx1 = _mm_load_si128((__m128i *) &l1[idx1 & MASK]); - } - - const __m128i ax0 = _mm_set_epi64x(ah0, al0); - const __m128i ax1 = _mm_set_epi64x(ah1, al1); - if (VARIANT == xmrig::VARIANT_TUBE) { - cx0 = aes_round_tweak_div(cx0, ax0); - cx1 = aes_round_tweak_div(cx1, ax1); - } - else if (SOFT_AES) { - cx0 = soft_aesenc((uint32_t*)&l0[idx0 & MASK], ax0, (const uint32_t*)saes_table); - cx1 = soft_aesenc((uint32_t*)&l1[idx1 & MASK], ax1, (const uint32_t*)saes_table); - } - else { - cx0 = _mm_aesenc_si128(cx0, ax0); - cx1 = _mm_aesenc_si128(cx1, ax1); - } - - if (BASE == xmrig::VARIANT_1 || (BASE == xmrig::VARIANT_2)) { - cryptonight_monero_tweak((uint64_t*)&l0[idx0 & MASK], l0, idx0 & MASK, ax0, bx00, bx01, cx0); - cryptonight_monero_tweak((uint64_t*)&l1[idx1 & MASK], l1, idx1 & MASK, ax1, bx10, bx11, cx1); - } else { - _mm_store_si128((__m128i *) &l0[idx0 & MASK], _mm_xor_si128(bx00, cx0)); - _mm_store_si128((__m128i *) &l1[idx1 & MASK], _mm_xor_si128(bx10, cx1)); - } - - idx0 = _mm_cvtsi128_si64(cx0); - idx1 = _mm_cvtsi128_si64(cx1); - - uint64_t hi, lo, cl, ch; - cl = ((uint64_t*) &l0[idx0 & MASK])[0]; - ch = ((uint64_t*) &l0[idx0 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(0, al0, ah0, cl, bx00, bx01); - if (VARIANT == xmrig::VARIANT_4) { - al0 ^= r0[2] | ((uint64_t)(r0[3]) << 32); - ah0 ^= r0[0] | ((uint64_t)(r0[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(0, cl, cx0); - } - } - - lo = __umul128(idx0, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l0, idx0 & MASK, ax0, bx00, bx01, cx0, 0); - } else { - VARIANT2_SHUFFLE2(l0, idx0 & MASK, ax0, bx00, bx01, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al0 += hi; - ah0 += lo; - - ((uint64_t*)&l0[idx0 & MASK])[0] = al0; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*) &l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0 ^ al0; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*) &l0[idx0 & MASK])[1] = ah0 ^ tweak1_2_0; - } else { - ((uint64_t*) &l0[idx0 & MASK])[1] = ah0; - } - - al0 ^= cl; - ah0 ^= ch; - idx0 = al0; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - int64_t n = ((int64_t*)&l0[idx0 & MASK])[0]; - int32_t d = ((int32_t*)&l0[idx0 & MASK])[2]; - int64_t q = n / (d | 0x5); - - ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - d = ~d; - } - - idx0 = d ^ q; - } - - cl = ((uint64_t*) &l1[idx1 & MASK])[0]; - ch = ((uint64_t*) &l1[idx1 & MASK])[1]; - - if (BASE == xmrig::VARIANT_2) { - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { - VARIANT4_RANDOM_MATH(1, al1, ah1, cl, bx10, bx11); - if (VARIANT == xmrig::VARIANT_4) { - al1 ^= r1[2] | ((uint64_t)(r1[3]) << 32); - ah1 ^= r1[0] | ((uint64_t)(r1[1]) << 32); - } - } else { - VARIANT2_INTEGER_MATH(1, cl, cx1); - } - } - - lo = __umul128(idx1, cl, &hi); - - if (BASE == xmrig::VARIANT_2) { - if (VARIANT == xmrig::VARIANT_4) { - VARIANT2_SHUFFLE(l1, idx1 & MASK, ax1, bx10, bx11, cx1, 0); - } else { - VARIANT2_SHUFFLE2(l1, idx1 & MASK, ax1, bx10, bx11, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); - } - } - - al1 += hi; - ah1 += lo; - - ((uint64_t*)&l1[idx1 & MASK])[0] = al1; - - if (BASE == xmrig::VARIANT_1 && (VARIANT == xmrig::VARIANT_TUBE || VARIANT == xmrig::VARIANT_RTO)) { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1 ^ al1; - } else if (BASE == xmrig::VARIANT_1) { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1 ^ tweak1_2_1; - } else { - ((uint64_t*)&l1[idx1 & MASK])[1] = ah1; - } - - al1 ^= cl; - ah1 ^= ch; - idx1 = al1; - - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { - int64_t n = ((int64_t*)&l1[idx1 & MASK])[0]; - int32_t d = ((int32_t*)&l1[idx1 & MASK])[2]; - int64_t q = n / (d | 0x5); - - ((int64_t*)&l1[idx1 & MASK])[0] = n ^ q; - - if (VARIANT == xmrig::VARIANT_XHV) { - d = ~d; - } - - idx1 = d ^ q; - } - - if (BASE == xmrig::VARIANT_2) { - bx01 = bx00; - bx11 = bx10; - } - - bx00 = cx0; - bx10 = cx1; - } - - cn_implode_scratchpad((__m128i*) l0, (__m128i*) h0); - cn_implode_scratchpad((__m128i*) l1, (__m128i*) h1); - - xmrig::keccakf(h0, 24); - xmrig::keccakf(h1, 24); - - extra_hashes[ctx[0]->state[0] & 3](ctx[0]->state, 200, output); - extra_hashes[ctx[1]->state[0] & 3](ctx[1]->state, 200, output + 32); -} - - -#define CN_STEP1(a, b0, b1, c, l, ptr, idx) \ - ptr = reinterpret_cast<__m128i*>(&l[idx & MASK]); \ - c = _mm_load_si128(ptr); - - -#define CN_STEP2(a, b0, b1, c, l, ptr, idx) \ - if (VARIANT == xmrig::VARIANT_TUBE) { \ - c = aes_round_tweak_div(c, a); \ - } \ - else if (SOFT_AES) { \ - c = soft_aesenc(&c, a, (const uint32_t*)saes_table); \ - } else { \ - c = _mm_aesenc_si128(c, a); \ - } \ - \ - if (BASE == xmrig::VARIANT_1 || BASE == xmrig::VARIANT_2) { \ - cryptonight_monero_tweak((uint64_t*)ptr, l, idx & MASK, a, b0, b1, c); \ - } else { \ - _mm_store_si128(ptr, _mm_xor_si128(b0, c)); \ - } - - -#define CN_STEP3(part, a, b0, b1, c, l, ptr, idx) \ - idx = _mm_cvtsi128_si64(c); \ - ptr = reinterpret_cast<__m128i*>(&l[idx & MASK]); \ - uint64_t cl##part = ((uint64_t*)ptr)[0]; \ - uint64_t ch##part = ((uint64_t*)ptr)[1]; - - -#define CN_STEP4(part, a, b0, b1, c, l, mc, ptr, idx) \ - uint64_t al##part, ah##part; \ - if (BASE == xmrig::VARIANT_2) { \ - if ((VARIANT == xmrig::VARIANT_WOW) || (VARIANT == xmrig::VARIANT_4)) { \ - al##part = _mm_cvtsi128_si64(a); \ - ah##part = _mm_cvtsi128_si64(_mm_srli_si128(a, 8)); \ - VARIANT4_RANDOM_MATH(part, al##part, ah##part, cl##part, b0, b1); \ - if (VARIANT == xmrig::VARIANT_4) { \ - al##part ^= r##part[2] | ((uint64_t)(r##part[3]) << 32); \ - ah##part ^= r##part[0] | ((uint64_t)(r##part[1]) << 32); \ - } \ - } else { \ - VARIANT2_INTEGER_MATH(part, cl##part, c); \ - } \ - } \ - lo = __umul128(idx, cl##part, &hi); \ - if (BASE == xmrig::VARIANT_2) { \ - if (VARIANT == xmrig::VARIANT_4) { \ - VARIANT2_SHUFFLE(l, idx & MASK, a, b0, b1, c, 0); \ - } else { \ - VARIANT2_SHUFFLE2(l, idx & MASK, a, b0, b1, hi, lo, (VARIANT == xmrig::VARIANT_RWZ ? 1 : 0)); \ - } \ - } \ - if (VARIANT == xmrig::VARIANT_4) { \ - a = _mm_set_epi64x(ah##part, al##part); \ - } \ - a = _mm_add_epi64(a, _mm_set_epi64x(lo, hi)); \ - \ - if (BASE == xmrig::VARIANT_1) { \ - _mm_store_si128(ptr, _mm_xor_si128(a, mc)); \ - \ - if (VARIANT == xmrig::VARIANT_TUBE || \ - VARIANT == xmrig::VARIANT_RTO) { \ - ((uint64_t*)ptr)[1] ^= ((uint64_t*)ptr)[0]; \ - } \ - } else { \ - _mm_store_si128(ptr, a); \ - } \ - \ - a = _mm_xor_si128(a, _mm_set_epi64x(ch##part, cl##part)); \ - idx = _mm_cvtsi128_si64(a); \ - \ - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { \ - int64_t n = ((int64_t*)&l[idx & MASK])[0]; \ - int32_t d = ((int32_t*)&l[idx & MASK])[2]; \ - int64_t q = n / (d | 0x5); \ - ((int64_t*)&l[idx & MASK])[0] = n ^ q; \ - if (VARIANT == xmrig::VARIANT_XHV) { \ - d = ~d; \ - } \ - \ - idx = d ^ q; \ - } \ - if (BASE == xmrig::VARIANT_2) { \ - b1 = b0; \ - } \ - b0 = c; - - -#define CONST_INIT(ctx, n) \ - __m128i mc##n; \ - __m128i division_result_xmm_##n; \ - __m128i sqrt_result_xmm_##n; \ - if (BASE == xmrig::VARIANT_1) { \ - mc##n = _mm_set_epi64x(*reinterpret_cast(input + n * size + 35) ^ \ - *(reinterpret_cast((ctx)->state) + 24), 0); \ - } \ - if (BASE == xmrig::VARIANT_2) { \ - division_result_xmm_##n = _mm_cvtsi64_si128(h##n[12]); \ - sqrt_result_xmm_##n = _mm_cvtsi64_si128(h##n[13]); \ - } \ - __m128i ax##n = _mm_set_epi64x(h##n[1] ^ h##n[5], h##n[0] ^ h##n[4]); \ - __m128i bx##n##0 = _mm_set_epi64x(h##n[3] ^ h##n[7], h##n[2] ^ h##n[6]); \ - __m128i bx##n##1 = _mm_set_epi64x(h##n[9] ^ h##n[11], h##n[8] ^ h##n[10]); \ - __m128i cx##n = _mm_setzero_si128(); \ - VARIANT4_RANDOM_MATH_INIT(n); - - -template -inline void cryptonight_triple_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 32 * 3); - return; - } - - for (size_t i = 0; i < 3; i++) { - xmrig::keccak(input + size * i, size, ctx[i]->state); - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->state), reinterpret_cast<__m128i*>(ctx[i]->memory)); - } - - uint8_t* l0 = ctx[0]->memory; - uint8_t* l1 = ctx[1]->memory; - uint8_t* l2 = ctx[2]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - uint64_t* h1 = reinterpret_cast(ctx[1]->state); - uint64_t* h2 = reinterpret_cast(ctx[2]->state); - - CONST_INIT(ctx[0], 0); - CONST_INIT(ctx[1], 1); - CONST_INIT(ctx[2], 2); - VARIANT2_SET_ROUNDING_MODE(); - - uint64_t idx0, idx1, idx2; - idx0 = _mm_cvtsi128_si64(ax0); - idx1 = _mm_cvtsi128_si64(ax1); - idx2 = _mm_cvtsi128_si64(ax2); - - for (size_t i = 0; i < ITERATIONS; i++) { - uint64_t hi, lo; - __m128i *ptr0, *ptr1, *ptr2; - - CN_STEP1(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP1(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP1(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - - CN_STEP2(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP2(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP2(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - - CN_STEP3(0, ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP3(1, ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP3(2, ax2, bx20, bx21, cx2, l2, ptr2, idx2); - - CN_STEP4(0, ax0, bx00, bx01, cx0, l0, mc0, ptr0, idx0); - CN_STEP4(1, ax1, bx10, bx11, cx1, l1, mc1, ptr1, idx1); - CN_STEP4(2, ax2, bx20, bx21, cx2, l2, mc2, ptr2, idx2); - } - - for (size_t i = 0; i < 3; i++) { - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->memory), reinterpret_cast<__m128i*>(ctx[i]->state)); - xmrig::keccakf(reinterpret_cast(ctx[i]->state), 24); - extra_hashes[ctx[i]->state[0] & 3](ctx[i]->state, 200, output + 32 * i); - } -} - - -template -inline void cryptonight_quad_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 32 * 4); - return; - } - - for (size_t i = 0; i < 4; i++) { - xmrig::keccak(input + size * i, size, ctx[i]->state); - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->state), reinterpret_cast<__m128i*>(ctx[i]->memory)); - } - - uint8_t* l0 = ctx[0]->memory; - uint8_t* l1 = ctx[1]->memory; - uint8_t* l2 = ctx[2]->memory; - uint8_t* l3 = ctx[3]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - uint64_t* h1 = reinterpret_cast(ctx[1]->state); - uint64_t* h2 = reinterpret_cast(ctx[2]->state); - uint64_t* h3 = reinterpret_cast(ctx[3]->state); - - CONST_INIT(ctx[0], 0); - CONST_INIT(ctx[1], 1); - CONST_INIT(ctx[2], 2); - CONST_INIT(ctx[3], 3); - VARIANT2_SET_ROUNDING_MODE(); - - uint64_t idx0, idx1, idx2, idx3; - idx0 = _mm_cvtsi128_si64(ax0); - idx1 = _mm_cvtsi128_si64(ax1); - idx2 = _mm_cvtsi128_si64(ax2); - idx3 = _mm_cvtsi128_si64(ax3); - - for (size_t i = 0; i < ITERATIONS; i++) - { - uint64_t hi, lo; - __m128i *ptr0, *ptr1, *ptr2, *ptr3; - - CN_STEP1(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP1(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP1(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP1(ax3, bx30, bx31, cx3, l3, ptr3, idx3); - - CN_STEP2(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP2(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP2(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP2(ax3, bx30, bx31, cx3, l3, ptr3, idx3); - - CN_STEP3(0, ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP3(1, ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP3(2, ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP3(3, ax3, bx30, bx31, cx3, l3, ptr3, idx3); - - CN_STEP4(0, ax0, bx00, bx01, cx0, l0, mc0, ptr0, idx0); - CN_STEP4(1, ax1, bx10, bx11, cx1, l1, mc1, ptr1, idx1); - CN_STEP4(2, ax2, bx20, bx21, cx2, l2, mc2, ptr2, idx2); - CN_STEP4(3, ax3, bx30, bx31, cx3, l3, mc3, ptr3, idx3); - } - - for (size_t i = 0; i < 4; i++) { - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->memory), reinterpret_cast<__m128i*>(ctx[i]->state)); - xmrig::keccakf(reinterpret_cast(ctx[i]->state), 24); - extra_hashes[ctx[i]->state[0] & 3](ctx[i]->state, 200, output + 32 * i); - } -} - - -template -inline void cryptonight_penta_hash(const uint8_t *__restrict__ input, size_t size, uint8_t *__restrict__ output, cryptonight_ctx **__restrict__ ctx, uint64_t height) -{ - constexpr size_t MASK = xmrig::cn_select_mask(); - constexpr size_t ITERATIONS = xmrig::cn_select_iter(); - constexpr size_t MEM = xmrig::cn_select_memory(); - constexpr xmrig::Variant BASE = xmrig::cn_base_variant(); - - if (BASE == xmrig::VARIANT_1 && size < 43) { - memset(output, 0, 32 * 5); - return; - } - - for (size_t i = 0; i < 5; i++) { - xmrig::keccak(input + size * i, size, ctx[i]->state); - cn_explode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->state), reinterpret_cast<__m128i*>(ctx[i]->memory)); - } - - uint8_t* l0 = ctx[0]->memory; - uint8_t* l1 = ctx[1]->memory; - uint8_t* l2 = ctx[2]->memory; - uint8_t* l3 = ctx[3]->memory; - uint8_t* l4 = ctx[4]->memory; - uint64_t* h0 = reinterpret_cast(ctx[0]->state); - uint64_t* h1 = reinterpret_cast(ctx[1]->state); - uint64_t* h2 = reinterpret_cast(ctx[2]->state); - uint64_t* h3 = reinterpret_cast(ctx[3]->state); - uint64_t* h4 = reinterpret_cast(ctx[4]->state); - - CONST_INIT(ctx[0], 0); - CONST_INIT(ctx[1], 1); - CONST_INIT(ctx[2], 2); - CONST_INIT(ctx[3], 3); - CONST_INIT(ctx[4], 4); - VARIANT2_SET_ROUNDING_MODE(); - - uint64_t idx0, idx1, idx2, idx3, idx4; - idx0 = _mm_cvtsi128_si64(ax0); - idx1 = _mm_cvtsi128_si64(ax1); - idx2 = _mm_cvtsi128_si64(ax2); - idx3 = _mm_cvtsi128_si64(ax3); - idx4 = _mm_cvtsi128_si64(ax4); - - for (size_t i = 0; i < ITERATIONS; i++) - { - uint64_t hi, lo; - __m128i *ptr0, *ptr1, *ptr2, *ptr3, *ptr4; - - CN_STEP1(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP1(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP1(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP1(ax3, bx30, bx31, cx3, l3, ptr3, idx3); - CN_STEP1(ax4, bx40, bx41, cx4, l4, ptr4, idx4); - - CN_STEP2(ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP2(ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP2(ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP2(ax3, bx30, bx31, cx3, l3, ptr3, idx3); - CN_STEP2(ax4, bx40, bx41, cx4, l4, ptr4, idx4); - - CN_STEP3(0, ax0, bx00, bx01, cx0, l0, ptr0, idx0); - CN_STEP3(1, ax1, bx10, bx11, cx1, l1, ptr1, idx1); - CN_STEP3(2, ax2, bx20, bx21, cx2, l2, ptr2, idx2); - CN_STEP3(3, ax3, bx30, bx31, cx3, l3, ptr3, idx3); - CN_STEP3(4, ax4, bx40, bx41, cx4, l4, ptr4, idx4); - - CN_STEP4(0, ax0, bx00, bx01, cx0, l0, mc0, ptr0, idx0); - CN_STEP4(1, ax1, bx10, bx11, cx1, l1, mc1, ptr1, idx1); - CN_STEP4(2, ax2, bx20, bx21, cx2, l2, mc2, ptr2, idx2); - CN_STEP4(3, ax3, bx30, bx31, cx3, l3, mc3, ptr3, idx3); - CN_STEP4(4, ax4, bx40, bx41, cx4, l4, mc4, ptr4, idx4); - } - - for (size_t i = 0; i < 5; i++) { - cn_implode_scratchpad(reinterpret_cast<__m128i*>(ctx[i]->memory), reinterpret_cast<__m128i*>(ctx[i]->state)); - xmrig::keccakf(reinterpret_cast(ctx[i]->state), 24); - extra_hashes[ctx[i]->state[0] & 3](ctx[i]->state, 200, output + 32 * i); - } -} - -#endif /* XMRIG_CRYPTONIGHT_X86_H */ diff --git a/src/Native/libcryptonight/xmrig/crypto/CryptonightR_gen.cpp b/src/Native/libcryptonight/xmrig/crypto/CryptonightR_gen.cpp deleted file mode 100644 index 3fba49cd95..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/CryptonightR_gen.cpp +++ /dev/null @@ -1,187 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018 Lee Clagett - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "crypto/CryptoNight_monero.h" - -typedef void(*void_func)(); - -#include "crypto/asm/CryptonightR_template.h" -#include "Mem.h" - - -static inline void add_code(uint8_t* &p, void (*p1)(), void (*p2)()) -{ - const ptrdiff_t size = reinterpret_cast(p2) - reinterpret_cast(p1); - if (size > 0) { - memcpy(p, reinterpret_cast(p1), size); - p += size; - } -} - -static inline void add_random_math(uint8_t* &p, const V4_Instruction* code, int code_size, const void_func* instructions, const void_func* instructions_mov, bool is_64_bit, xmrig::Assembly ASM) -{ - uint32_t prev_rot_src = (uint32_t)(-1); - - for (int i = 0;; ++i) { - const V4_Instruction inst = code[i]; - if (inst.opcode == RET) { - break; - } - - uint8_t opcode = (inst.opcode == MUL) ? inst.opcode : (inst.opcode + 2); - uint8_t dst_index = inst.dst_index; - uint8_t src_index = inst.src_index; - - const uint32_t a = inst.dst_index; - const uint32_t b = inst.src_index; - const uint8_t c = opcode | (dst_index << V4_OPCODE_BITS) | (((src_index == 8) ? dst_index : src_index) << (V4_OPCODE_BITS + V4_DST_INDEX_BITS)); - - switch (inst.opcode) { - case ROR: - case ROL: - if (b != prev_rot_src) { - prev_rot_src = b; - add_code(p, instructions_mov[c], instructions_mov[c + 1]); - } - break; - } - - if (a == prev_rot_src) { - prev_rot_src = (uint32_t)(-1); - } - - void_func begin = instructions[c]; - - if ((ASM = xmrig::ASM_BULLDOZER) && (inst.opcode == MUL) && !is_64_bit) { - // AMD Bulldozer has latency 4 for 32-bit IMUL and 6 for 64-bit IMUL - // Always use 32-bit IMUL for AMD Bulldozer in 32-bit mode - skip prefix 0x48 and change 0x49 to 0x41 - uint8_t* prefix = reinterpret_cast(begin); - - if (*prefix == 0x49) { - *(p++) = 0x41; - } - - begin = reinterpret_cast(prefix + 1); - } - - add_code(p, begin, instructions[c + 1]); - - if (inst.opcode == ADD) { - *(uint32_t*)(p - sizeof(uint32_t) - (is_64_bit ? 3 : 0)) = inst.C; - if (is_64_bit) { - prev_rot_src = (uint32_t)(-1); - } - } - } -} - -void wow_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightWOW_template_part1, CryptonightWOW_template_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightWOW_template_part2, CryptonightWOW_template_part3); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightWOW_template_mainloop) - ((const uint8_t*)CryptonightWOW_template_part1)) - (p - p0)); - add_code(p, CryptonightWOW_template_part3, CryptonightWOW_template_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} - -void v4_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightR_template_part1, CryptonightR_template_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightR_template_part2, CryptonightR_template_part3); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightR_template_mainloop) - ((const uint8_t*)CryptonightR_template_part1)) - (p - p0)); - add_code(p, CryptonightR_template_part3, CryptonightR_template_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} - -void wow_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightWOW_template_double_part1, CryptonightWOW_template_double_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightWOW_template_double_part2, CryptonightWOW_template_double_part3); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightWOW_template_double_part3, CryptonightWOW_template_double_part4); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightWOW_template_double_mainloop) - ((const uint8_t*)CryptonightWOW_template_double_part1)) - (p - p0)); - add_code(p, CryptonightWOW_template_double_part4, CryptonightWOW_template_double_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} - -void v4_compile_code_double(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightR_template_double_part1, CryptonightR_template_double_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightR_template_double_part2, CryptonightR_template_double_part3); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightR_template_double_part3, CryptonightR_template_double_part4); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightR_template_double_mainloop) - ((const uint8_t*)CryptonightR_template_double_part1)) - (p - p0)); - add_code(p, CryptonightR_template_double_part4, CryptonightR_template_double_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} - -void wow_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightWOW_soft_aes_template_part1, CryptonightWOW_soft_aes_template_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightWOW_soft_aes_template_part2, CryptonightWOW_soft_aes_template_part3); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightWOW_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightWOW_soft_aes_template_part1)) - (p - p0)); - add_code(p, CryptonightWOW_soft_aes_template_part3, CryptonightWOW_soft_aes_template_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} - -void v4_soft_aes_compile_code(const V4_Instruction* code, int code_size, void* machine_code, xmrig::Assembly ASM) -{ - uint8_t* p0 = reinterpret_cast(machine_code); - uint8_t* p = p0; - - add_code(p, CryptonightR_soft_aes_template_part1, CryptonightR_soft_aes_template_part2); - add_random_math(p, code, code_size, instructions, instructions_mov, false, ASM); - add_code(p, CryptonightR_soft_aes_template_part2, CryptonightR_soft_aes_template_part3); - *(int*)(p - 4) = static_cast((((const uint8_t*)CryptonightR_soft_aes_template_mainloop) - ((const uint8_t*)CryptonightR_soft_aes_template_part1)) - (p - p0)); - add_code(p, CryptonightR_soft_aes_template_part3, CryptonightR_soft_aes_template_end); - - Mem::flushInstructionCache(machine_code, p - p0); -} diff --git a/src/Native/libcryptonight/xmrig/crypto/SSE2NEON.h b/src/Native/libcryptonight/xmrig/crypto/SSE2NEON.h deleted file mode 100644 index 6a00448d60..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/SSE2NEON.h +++ /dev/null @@ -1,1497 +0,0 @@ -#ifndef SSE2NEON_H -#define SSE2NEON_H - -// This header file provides a simple API translation layer -// between SSE intrinsics to their corresponding ARM NEON versions -// -// This header file does not (yet) translate *all* of the SSE intrinsics. -// Since this is in support of a specific porting effort, I have only -// included the intrinsics I needed to get my port to work. -// -// Questions/Comments/Feedback send to: jratcliffscarab@gmail.com -// -// If you want to improve or add to this project, send me an -// email and I will probably approve your access to the depot. -// -// Project is located here: -// -// https://github.com/jratcliff63367/sse2neon -// -// Show your appreciation for open source by sending me a bitcoin tip to the following -// address. -// -// TipJar: 1PzgWDSyq4pmdAXRH8SPUtta4SWGrt4B1p : -// https://blockchain.info/address/1PzgWDSyq4pmdAXRH8SPUtta4SWGrt4B1p -// -// -// Contributors to this project are: -// -// John W. Ratcliff : jratcliffscarab@gmail.com -// Brandon Rowlett : browlett@nvidia.com -// Ken Fast : kfast@gdeb.com -// Eric van Beurden : evanbeurden@nvidia.com -// Alexander Potylitsin : apotylitsin@nvidia.com -// -// -// ********************************************************************************************************************* -// apoty: March 17, 2017 -// Current version was changed in most to fix issues and potential issues. -// All unit tests were rewritten as a part of forge lib project to cover all implemented functions. -// ********************************************************************************************************************* -// Release notes for January 20, 2017 version: -// -// The unit tests have been refactored. They no longer assert on an error, instead they return a pass/fail condition -// The unit-tests now test 10,000 random float and int values against each intrinsic. -// -// SSE2NEON now supports 95 SSE intrinsics. 39 of them have formal unit tests which have been implemented and -// fully tested on NEON/ARM. The remaining 56 still need unit tests implemented. -// -// A struct is now defined in this header file called 'SIMDVec' which can be used by applications which -// attempt to access the contents of an _m128 struct directly. It is important to note that accessing the __m128 -// struct directly is bad coding practice by Microsoft: @see: https://msdn.microsoft.com/en-us/library/ayeb3ayc.aspx -// -// However, some legacy source code may try to access the contents of an __m128 struct directly so the developer -// can use the SIMDVec as an alias for it. Any casting must be done manually by the developer, as you cannot -// cast or otherwise alias the base NEON data type for intrinsic operations. -// -// A bug was found with the _mm_shuffle_ps intrinsic. If the shuffle permutation was not one of the ones with -// a custom/unique implementation causing it to fall through to the default shuffle implementation it was failing -// to return the correct value. This is now fixed. -// -// A bug was found with the _mm_cvtps_epi32 intrinsic. This converts floating point values to integers. -// It was not honoring the correct rounding mode. In SSE the default rounding mode when converting from float to int -// is to use 'round to even' otherwise known as 'bankers rounding'. ARMv7 did not support this feature but ARMv8 does. -// As it stands today, this header file assumes ARMv8. If you are trying to target really old ARM devices, you may get -// a build error. -// -// Support for a number of new intrinsics was added, however, none of them yet have unit-tests to 100% confirm they are -// producing the correct results on NEON. These unit tests will be added as soon as possible. -// -// Here is the list of new instrinsics which have been added: -// -// _mm_cvtss_f32 : extracts the lower order floating point value from the parameter -// _mm_add_ss : adds the scalar single - precision floating point values of a and b -// _mm_div_ps : Divides the four single - precision, floating - point values of a and b. -// _mm_div_ss : Divides the scalar single - precision floating point value of a by b. -// _mm_sqrt_ss : Computes the approximation of the square root of the scalar single - precision floating point value of in. -// _mm_rsqrt_ps : Computes the approximations of the reciprocal square roots of the four single - precision floating point values of in. -// _mm_comilt_ss : Compares the lower single - precision floating point scalar values of a and b using a less than operation -// _mm_comigt_ss : Compares the lower single - precision floating point scalar values of a and b using a greater than operation. -// _mm_comile_ss : Compares the lower single - precision floating point scalar values of a and b using a less than or equal operation. -// _mm_comige_ss : Compares the lower single - precision floating point scalar values of a and b using a greater than or equal operation. -// _mm_comieq_ss : Compares the lower single - precision floating point scalar values of a and b using an equality operation. -// _mm_comineq_s : Compares the lower single - precision floating point scalar values of a and b using an inequality operation -// _mm_unpackhi_epi8 : Interleaves the upper 8 signed or unsigned 8 - bit integers in a with the upper 8 signed or unsigned 8 - bit integers in b. -// _mm_unpackhi_epi16: Interleaves the upper 4 signed or unsigned 16 - bit integers in a with the upper 4 signed or unsigned 16 - bit integers in b. -// -// ********************************************************************************************************************* -/* -** The MIT license: -** -** Permission is hereby granted, free of charge, to any person obtaining a copy -** of this software and associated documentation files (the "Software"), to deal -** in the Software without restriction, including without limitation the rights -** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -** copies of the Software, and to permit persons to whom the Software is furnished -** to do so, subject to the following conditions: -** -** The above copyright notice and this permission notice shall be included in all -** copies or substantial portions of the Software. - -** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -** WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#define ENABLE_CPP_VERSION 0 - -#if defined(__GNUC__) || defined(__clang__) -# pragma push_macro("FORCE_INLINE") -# pragma push_macro("ALIGN_STRUCT") -# define FORCE_INLINE static inline __attribute__((always_inline)) -# define ALIGN_STRUCT(x) __attribute__((aligned(x))) -#else -# error "Macro name collisions may happens with unknown compiler" -# define FORCE_INLINE static inline -# define ALIGN_STRUCT(x) __declspec(align(x)) -#endif - -#include -#include "arm_neon.h" - - -/*******************************************************/ -/* MACRO for shuffle parameter for _mm_shuffle_ps(). */ -/* Argument fp3 is a digit[0123] that represents the fp*/ -/* from argument "b" of mm_shuffle_ps that will be */ -/* placed in fp3 of result. fp2 is the same for fp2 in */ -/* result. fp1 is a digit[0123] that represents the fp */ -/* from argument "a" of mm_shuffle_ps that will be */ -/* places in fp1 of result. fp0 is the same for fp0 of */ -/* result */ -/*******************************************************/ -#define _MM_SHUFFLE(fp3,fp2,fp1,fp0) \ - (((fp3) << 6) | ((fp2) << 4) | ((fp1) << 2) | ((fp0))) - -/* indicate immediate constant argument in a given range */ -#define __constrange(a,b) \ - const - -typedef float32x4_t __m128; -typedef int32x4_t __m128i; - - -// ****************************************** -// type-safe casting between types -// ****************************************** - -#define vreinterpretq_m128_f16(x) \ - vreinterpretq_f32_f16(x) - -#define vreinterpretq_m128_f32(x) \ - (x) - -#define vreinterpretq_m128_f64(x) \ - vreinterpretq_f32_f64(x) - - -#define vreinterpretq_m128_u8(x) \ - vreinterpretq_f32_u8(x) - -#define vreinterpretq_m128_u16(x) \ - vreinterpretq_f32_u16(x) - -#define vreinterpretq_m128_u32(x) \ - vreinterpretq_f32_u32(x) - -#define vreinterpretq_m128_u64(x) \ - vreinterpretq_f32_u64(x) - - -#define vreinterpretq_m128_s8(x) \ - vreinterpretq_f32_s8(x) - -#define vreinterpretq_m128_s16(x) \ - vreinterpretq_f32_s16(x) - -#define vreinterpretq_m128_s32(x) \ - vreinterpretq_f32_s32(x) - -#define vreinterpretq_m128_s64(x) \ - vreinterpretq_f32_s64(x) - - -#define vreinterpretq_f16_m128(x) \ - vreinterpretq_f16_f32(x) - -#define vreinterpretq_f32_m128(x) \ - (x) - -#define vreinterpretq_f64_m128(x) \ - vreinterpretq_f64_f32(x) - - -#define vreinterpretq_u8_m128(x) \ - vreinterpretq_u8_f32(x) - -#define vreinterpretq_u16_m128(x) \ - vreinterpretq_u16_f32(x) - -#define vreinterpretq_u32_m128(x) \ - vreinterpretq_u32_f32(x) - -#define vreinterpretq_u64_m128(x) \ - vreinterpretq_u64_f32(x) - - -#define vreinterpretq_s8_m128(x) \ - vreinterpretq_s8_f32(x) - -#define vreinterpretq_s16_m128(x) \ - vreinterpretq_s16_f32(x) - -#define vreinterpretq_s32_m128(x) \ - vreinterpretq_s32_f32(x) - -#define vreinterpretq_s64_m128(x) \ - vreinterpretq_s64_f32(x) - - -#define vreinterpretq_m128i_s8(x) \ - vreinterpretq_s32_s8(x) - -#define vreinterpretq_m128i_s16(x) \ - vreinterpretq_s32_s16(x) - -#define vreinterpretq_m128i_s32(x) \ - (x) - -#define vreinterpretq_m128i_s64(x) \ - vreinterpretq_s32_s64(x) - - -#define vreinterpretq_m128i_u8(x) \ - vreinterpretq_s32_u8(x) - -#define vreinterpretq_m128i_u16(x) \ - vreinterpretq_s32_u16(x) - -#define vreinterpretq_m128i_u32(x) \ - vreinterpretq_s32_u32(x) - -#define vreinterpretq_m128i_u64(x) \ - vreinterpretq_s32_u64(x) - - -#define vreinterpretq_s8_m128i(x) \ - vreinterpretq_s8_s32(x) - -#define vreinterpretq_s16_m128i(x) \ - vreinterpretq_s16_s32(x) - -#define vreinterpretq_s32_m128i(x) \ - (x) - -#define vreinterpretq_s64_m128i(x) \ - vreinterpretq_s64_s32(x) - - -#define vreinterpretq_u8_m128i(x) \ - vreinterpretq_u8_s32(x) - -#define vreinterpretq_u16_m128i(x) \ - vreinterpretq_u16_s32(x) - -#define vreinterpretq_u32_m128i(x) \ - vreinterpretq_u32_s32(x) - -#define vreinterpretq_u64_m128i(x) \ - vreinterpretq_u64_s32(x) - - -// union intended to allow direct access to an __m128 variable using the names that the MSVC -// compiler provides. This union should really only be used when trying to access the members -// of the vector as integer values. GCC/clang allow native access to the float members through -// a simple array access operator (in C since 4.6, in C++ since 4.8). -// -// Ideally direct accesses to SIMD vectors should not be used since it can cause a performance -// hit. If it really is needed however, the original __m128 variable can be aliased with a -// pointer to this union and used to access individual components. The use of this union should -// be hidden behind a macro that is used throughout the codebase to access the members instead -// of always declaring this type of variable. -typedef union ALIGN_STRUCT(16) SIMDVec -{ - float m128_f32[4]; // as floats - do not to use this. Added for convenience. - int8_t m128_i8[16]; // as signed 8-bit integers. - int16_t m128_i16[8]; // as signed 16-bit integers. - int32_t m128_i32[4]; // as signed 32-bit integers. - int64_t m128_i64[2]; // as signed 64-bit integers. - uint8_t m128_u8[16]; // as unsigned 8-bit integers. - uint16_t m128_u16[8]; // as unsigned 16-bit integers. - uint32_t m128_u32[4]; // as unsigned 32-bit integers. - uint64_t m128_u64[2]; // as unsigned 64-bit integers. -} SIMDVec; - - -// ****************************************** -// Set/get methods -// ****************************************** - -// extracts the lower order floating point value from the parameter : https://msdn.microsoft.com/en-us/library/bb514059%28v=vs.120%29.aspx?f=255&MSPPError=-2147217396 -FORCE_INLINE float _mm_cvtss_f32(__m128 a) -{ - return vgetq_lane_f32(vreinterpretq_f32_m128(a), 0); -} - -// Sets the 128-bit value to zero https://msdn.microsoft.com/en-us/library/vstudio/ys7dw0kh(v=vs.100).aspx -FORCE_INLINE __m128i _mm_setzero_si128() -{ - return vreinterpretq_m128i_s32(vdupq_n_s32(0)); -} - -// Clears the four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/vstudio/tk1t2tbz(v=vs.100).aspx -FORCE_INLINE __m128 _mm_setzero_ps(void) -{ - return vreinterpretq_m128_f32(vdupq_n_f32(0)); -} - -// Sets the four single-precision, floating-point values to w. https://msdn.microsoft.com/en-us/library/vstudio/2x1se8ha(v=vs.100).aspx -FORCE_INLINE __m128 _mm_set1_ps(float _w) -{ - return vreinterpretq_m128_f32(vdupq_n_f32(_w)); -} - -// Sets the four single-precision, floating-point values to w. https://msdn.microsoft.com/en-us/library/vstudio/2x1se8ha(v=vs.100).aspx -FORCE_INLINE __m128 _mm_set_ps1(float _w) -{ - return vreinterpretq_m128_f32(vdupq_n_f32(_w)); -} - -// Sets the four single-precision, floating-point values to the four inputs. https://msdn.microsoft.com/en-us/library/vstudio/afh0zf75(v=vs.100).aspx -FORCE_INLINE __m128 _mm_set_ps(float w, float z, float y, float x) -{ - float __attribute__((aligned(16))) data[4] = { x, y, z, w }; - return vreinterpretq_m128_f32(vld1q_f32(data)); -} - -// Sets the four single-precision, floating-point values to the four inputs in reverse order. https://msdn.microsoft.com/en-us/library/vstudio/d2172ct3(v=vs.100).aspx -FORCE_INLINE __m128 _mm_setr_ps(float w, float z , float y , float x ) -{ - float __attribute__ ((aligned (16))) data[4] = { w, z, y, x }; - return vreinterpretq_m128_f32(vld1q_f32(data)); -} - -// Sets the 4 signed 32-bit integer values to i. https://msdn.microsoft.com/en-us/library/vstudio/h4xscxat(v=vs.100).aspx -FORCE_INLINE __m128i _mm_set1_epi32(int _i) -{ - return vreinterpretq_m128i_s32(vdupq_n_s32(_i)); -} - -// Sets the 4 signed 32-bit integer values. https://msdn.microsoft.com/en-us/library/vstudio/019beekt(v=vs.100).aspx -FORCE_INLINE __m128i _mm_set_epi32(int i3, int i2, int i1, int i0) -{ - int32_t __attribute__((aligned(16))) data[4] = { i0, i1, i2, i3 }; - return vreinterpretq_m128i_s32(vld1q_s32(data)); -} - -// Stores four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/vstudio/s3h4ay6y(v=vs.100).aspx -FORCE_INLINE void _mm_store_ps(float *p, __m128 a) -{ - vst1q_f32(p, vreinterpretq_f32_m128(a)); -} - -// Stores four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/44e30x22(v=vs.100).aspx -FORCE_INLINE void _mm_storeu_ps(float *p, __m128 a) -{ - vst1q_f32(p, vreinterpretq_f32_m128(a)); -} - -// Stores four 32-bit integer values as (as a __m128i value) at the address p. https://msdn.microsoft.com/en-us/library/vstudio/edk11s13(v=vs.100).aspx -FORCE_INLINE void _mm_store_si128(__m128i *p, __m128i a) -{ - vst1q_s32((int32_t*) p, vreinterpretq_s32_m128i(a)); -} - -// Stores the lower single - precision, floating - point value. https://msdn.microsoft.com/en-us/library/tzz10fbx(v=vs.100).aspx -FORCE_INLINE void _mm_store_ss(float *p, __m128 a) -{ - vst1q_lane_f32(p, vreinterpretq_f32_m128(a), 0); -} - -// Reads the lower 64 bits of b and stores them into the lower 64 bits of a. https://msdn.microsoft.com/en-us/library/hhwf428f%28v=vs.90%29.aspx -FORCE_INLINE void _mm_storel_epi64(__m128i* a, __m128i b) -{ - uint64x1_t hi = vget_high_u64(vreinterpretq_u64_m128i(*a)); - uint64x1_t lo = vget_low_u64(vreinterpretq_u64_m128i(b)); - *a = vreinterpretq_m128i_u64(vcombine_u64(lo, hi)); -} - -// Loads a single single-precision, floating-point value, copying it into all four words https://msdn.microsoft.com/en-us/library/vstudio/5cdkf716(v=vs.100).aspx -FORCE_INLINE __m128 _mm_load1_ps(const float * p) -{ - return vreinterpretq_m128_f32(vld1q_dup_f32(p)); -} - -// Loads four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/vstudio/zzd50xxt(v=vs.100).aspx -FORCE_INLINE __m128 _mm_load_ps(const float * p) -{ - return vreinterpretq_m128_f32(vld1q_f32(p)); -} - -// Loads four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/x1b16s7z%28v=vs.90%29.aspx -FORCE_INLINE __m128 _mm_loadu_ps(const float * p) -{ - // for neon, alignment doesn't matter, so _mm_load_ps and _mm_loadu_ps are equivalent for neon - return vreinterpretq_m128_f32(vld1q_f32(p)); -} - -// Loads an single - precision, floating - point value into the low word and clears the upper three words. https://msdn.microsoft.com/en-us/library/548bb9h4%28v=vs.90%29.aspx -FORCE_INLINE __m128 _mm_load_ss(const float * p) -{ - return vreinterpretq_m128_f32(vsetq_lane_f32(*p, vdupq_n_f32(0), 0)); -} - - -// ****************************************** -// Logic/Binary operations -// ****************************************** - -// Compares for inequality. https://msdn.microsoft.com/en-us/library/sf44thbx(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmpneq_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32( vmvnq_u32( vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)) ) ); -} - -// Computes the bitwise AND-NOT of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/68h7wd02(v=vs.100).aspx -FORCE_INLINE __m128 _mm_andnot_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_s32( vbicq_s32(vreinterpretq_s32_m128(b), vreinterpretq_s32_m128(a)) ); // *NOTE* argument swap -} - -// Computes the bitwise AND of the 128-bit value in b and the bitwise NOT of the 128-bit value in a. https://msdn.microsoft.com/en-us/library/vstudio/1beaceh8(v=vs.100).aspx -FORCE_INLINE __m128i _mm_andnot_si128(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32( vbicq_s32(vreinterpretq_s32_m128i(b), vreinterpretq_s32_m128i(a)) ); // *NOTE* argument swap -} - -// Computes the bitwise AND of the 128-bit value in a and the 128-bit value in b. https://msdn.microsoft.com/en-us/library/vstudio/6d1txsa8(v=vs.100).aspx -FORCE_INLINE __m128i _mm_and_si128(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32( vandq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b)) ); -} - -// Computes the bitwise AND of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/73ck1xc5(v=vs.100).aspx -FORCE_INLINE __m128 _mm_and_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_s32( vandq_s32(vreinterpretq_s32_m128(a), vreinterpretq_s32_m128(b)) ); -} - -// Computes the bitwise OR of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/7ctdsyy0(v=vs.100).aspx -FORCE_INLINE __m128 _mm_or_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_s32( vorrq_s32(vreinterpretq_s32_m128(a), vreinterpretq_s32_m128(b)) ); -} - -// Computes bitwise EXOR (exclusive-or) of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/ss6k3wk8(v=vs.100).aspx -FORCE_INLINE __m128 _mm_xor_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_s32( veorq_s32(vreinterpretq_s32_m128(a), vreinterpretq_s32_m128(b)) ); -} - -// Computes the bitwise OR of the 128-bit value in a and the 128-bit value in b. https://msdn.microsoft.com/en-us/library/vstudio/ew8ty0db(v=vs.100).aspx -FORCE_INLINE __m128i _mm_or_si128(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32( vorrq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b)) ); -} - -// Computes the bitwise XOR of the 128-bit value in a and the 128-bit value in b. https://msdn.microsoft.com/en-us/library/fzt08www(v=vs.100).aspx -FORCE_INLINE __m128i _mm_xor_si128(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32( veorq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b)) ); -} - -// NEON does not provide this method -// Creates a 4-bit mask from the most significant bits of the four single-precision, floating-point values. https://msdn.microsoft.com/en-us/library/vstudio/4490ys29(v=vs.100).aspx -FORCE_INLINE int _mm_movemask_ps(__m128 a) -{ -#if ENABLE_CPP_VERSION // I am not yet convinced that the NEON version is faster than the C version of this - uint32x4_t &ia = *(uint32x4_t *)&a; - return (ia[0] >> 31) | ((ia[1] >> 30) & 2) | ((ia[2] >> 29) & 4) | ((ia[3] >> 28) & 8); -#else - static const uint32x4_t movemask = { 1, 2, 4, 8 }; - static const uint32x4_t highbit = { 0x80000000, 0x80000000, 0x80000000, 0x80000000 }; - uint32x4_t t0 = vreinterpretq_u32_m128(a); - uint32x4_t t1 = vtstq_u32(t0, highbit); - uint32x4_t t2 = vandq_u32(t1, movemask); - uint32x2_t t3 = vorr_u32(vget_low_u32(t2), vget_high_u32(t2)); - return vget_lane_u32(t3, 0) | vget_lane_u32(t3, 1); -#endif -} - -// Takes the upper 64 bits of a and places it in the low end of the result -// Takes the lower 64 bits of b and places it into the high end of the result. -FORCE_INLINE __m128 _mm_shuffle_ps_1032(__m128 a, __m128 b) -{ - float32x2_t a32 = vget_high_f32(vreinterpretq_f32_m128(a)); - float32x2_t b10 = vget_low_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(a32, b10)); -} - -// takes the lower two 32-bit values from a and swaps them and places in high end of result -// takes the higher two 32 bit values from b and swaps them and places in low end of result. -FORCE_INLINE __m128 _mm_shuffle_ps_2301(__m128 a, __m128 b) -{ - float32x2_t a01 = vrev64_f32(vget_low_f32(vreinterpretq_f32_m128(a))); - float32x2_t b23 = vrev64_f32(vget_high_f32(vreinterpretq_f32_m128(b))); - return vreinterpretq_m128_f32(vcombine_f32(a01, b23)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_0321(__m128 a, __m128 b) -{ - float32x2_t a21 = vget_high_f32(vextq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a), 3)); - float32x2_t b03 = vget_low_f32(vextq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b), 3)); - return vreinterpretq_m128_f32(vcombine_f32(a21, b03)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_2103(__m128 a, __m128 b) -{ - float32x2_t a03 = vget_low_f32(vextq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a), 3)); - float32x2_t b21 = vget_high_f32(vextq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b), 3)); - return vreinterpretq_m128_f32(vcombine_f32(a03, b21)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_1010(__m128 a, __m128 b) -{ - float32x2_t a10 = vget_low_f32(vreinterpretq_f32_m128(a)); - float32x2_t b10 = vget_low_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(a10, b10)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_1001(__m128 a, __m128 b) -{ - float32x2_t a01 = vrev64_f32(vget_low_f32(vreinterpretq_f32_m128(a))); - float32x2_t b10 = vget_low_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(a01, b10)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_0101(__m128 a, __m128 b) -{ - float32x2_t a01 = vrev64_f32(vget_low_f32(vreinterpretq_f32_m128(a))); - float32x2_t b01 = vrev64_f32(vget_low_f32(vreinterpretq_f32_m128(b))); - return vreinterpretq_m128_f32(vcombine_f32(a01, b01)); -} - -// keeps the low 64 bits of b in the low and puts the high 64 bits of a in the high -FORCE_INLINE __m128 _mm_shuffle_ps_3210(__m128 a, __m128 b) -{ - float32x2_t a10 = vget_low_f32(vreinterpretq_f32_m128(a)); - float32x2_t b32 = vget_high_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(a10, b32)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_0011(__m128 a, __m128 b) -{ - float32x2_t a11 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(a)), 1); - float32x2_t b00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 0); - return vreinterpretq_m128_f32(vcombine_f32(a11, b00)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_0022(__m128 a, __m128 b) -{ - float32x2_t a22 = vdup_lane_f32(vget_high_f32(vreinterpretq_f32_m128(a)), 0); - float32x2_t b00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 0); - return vreinterpretq_m128_f32(vcombine_f32(a22, b00)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_2200(__m128 a, __m128 b) -{ - float32x2_t a00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(a)), 0); - float32x2_t b22 = vdup_lane_f32(vget_high_f32(vreinterpretq_f32_m128(b)), 0); - return vreinterpretq_m128_f32(vcombine_f32(a00, b22)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_3202(__m128 a, __m128 b) -{ - float32_t a0 = vgetq_lane_f32(vreinterpretq_f32_m128(a), 0); - float32x2_t a22 = vdup_lane_f32(vget_high_f32(vreinterpretq_f32_m128(a)), 0); - float32x2_t a02 = vset_lane_f32(a0, a22, 1); /* apoty: TODO: use vzip ?*/ - float32x2_t b32 = vget_high_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(a02, b32)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_1133(__m128 a, __m128 b) -{ - float32x2_t a33 = vdup_lane_f32(vget_high_f32(vreinterpretq_f32_m128(a)), 1); - float32x2_t b11 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 1); - return vreinterpretq_m128_f32(vcombine_f32(a33, b11)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_2010(__m128 a, __m128 b) -{ - float32x2_t a10 = vget_low_f32(vreinterpretq_f32_m128(a)); - float32_t b2 = vgetq_lane_f32(vreinterpretq_f32_m128(b), 2); - float32x2_t b00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 0); - float32x2_t b20 = vset_lane_f32(b2, b00, 1); - return vreinterpretq_m128_f32(vcombine_f32(a10, b20)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_2001(__m128 a, __m128 b) -{ - float32x2_t a01 = vrev64_f32(vget_low_f32(vreinterpretq_f32_m128(a))); - float32_t b2 = vgetq_lane_f32(b, 2); - float32x2_t b00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 0); - float32x2_t b20 = vset_lane_f32(b2, b00, 1); - return vreinterpretq_m128_f32(vcombine_f32(a01, b20)); -} - -FORCE_INLINE __m128 _mm_shuffle_ps_2032(__m128 a, __m128 b) -{ - float32x2_t a32 = vget_high_f32(vreinterpretq_f32_m128(a)); - float32_t b2 = vgetq_lane_f32(b, 2); - float32x2_t b00 = vdup_lane_f32(vget_low_f32(vreinterpretq_f32_m128(b)), 0); - float32x2_t b20 = vset_lane_f32(b2, b00, 1); - return vreinterpretq_m128_f32(vcombine_f32(a32, b20)); -} - -// NEON does not support a general purpose permute intrinsic -// Currently I am not sure whether the C implementation is faster or slower than the NEON version. -// Note, this has to be expanded as a template because the shuffle value must be an immediate value. -// The same is true on SSE as well. -// Selects four specific single-precision, floating-point values from a and b, based on the mask i. https://msdn.microsoft.com/en-us/library/vstudio/5f0858x0(v=vs.100).aspx -#if ENABLE_CPP_VERSION // I am not convinced that the NEON version is faster than the C version yet. -FORCE_INLINE __m128 _mm_shuffle_ps_default(__m128 a, __m128 b, __constrange(0,255) int imm) -{ - __m128 ret; - ret[0] = a[imm & 0x3]; - ret[1] = a[(imm >> 2) & 0x3]; - ret[2] = b[(imm >> 4) & 0x03]; - ret[3] = b[(imm >> 6) & 0x03]; - return ret; -} -#else -#define _mm_shuffle_ps_default(a, b, imm) \ -({ \ - float32x4_t ret; \ - ret = vmovq_n_f32(vgetq_lane_f32(vreinterpretq_f32_m128(a), (imm) & 0x3)); \ - ret = vsetq_lane_f32(vgetq_lane_f32(vreinterpretq_f32_m128(a), ((imm) >> 2) & 0x3), ret, 1); \ - ret = vsetq_lane_f32(vgetq_lane_f32(vreinterpretq_f32_m128(b), ((imm) >> 4) & 0x3), ret, 2); \ - ret = vsetq_lane_f32(vgetq_lane_f32(vreinterpretq_f32_m128(b), ((imm) >> 6) & 0x3), ret, 3); \ - vreinterpretq_m128_f32(ret); \ -}) -#endif - -//FORCE_INLINE __m128 _mm_shuffle_ps(__m128 a, __m128 b, __constrange(0,255) int imm) -#define _mm_shuffle_ps(a, b, imm) \ -({ \ - __m128 ret; \ - switch (imm) \ - { \ - case _MM_SHUFFLE(1, 0, 3, 2): ret = _mm_shuffle_ps_1032((a), (b)); break; \ - case _MM_SHUFFLE(2, 3, 0, 1): ret = _mm_shuffle_ps_2301((a), (b)); break; \ - case _MM_SHUFFLE(0, 3, 2, 1): ret = _mm_shuffle_ps_0321((a), (b)); break; \ - case _MM_SHUFFLE(2, 1, 0, 3): ret = _mm_shuffle_ps_2103((a), (b)); break; \ - case _MM_SHUFFLE(1, 0, 1, 0): ret = _mm_shuffle_ps_1010((a), (b)); break; \ - case _MM_SHUFFLE(1, 0, 0, 1): ret = _mm_shuffle_ps_1001((a), (b)); break; \ - case _MM_SHUFFLE(0, 1, 0, 1): ret = _mm_shuffle_ps_0101((a), (b)); break; \ - case _MM_SHUFFLE(3, 2, 1, 0): ret = _mm_shuffle_ps_3210((a), (b)); break; \ - case _MM_SHUFFLE(0, 0, 1, 1): ret = _mm_shuffle_ps_0011((a), (b)); break; \ - case _MM_SHUFFLE(0, 0, 2, 2): ret = _mm_shuffle_ps_0022((a), (b)); break; \ - case _MM_SHUFFLE(2, 2, 0, 0): ret = _mm_shuffle_ps_2200((a), (b)); break; \ - case _MM_SHUFFLE(3, 2, 0, 2): ret = _mm_shuffle_ps_3202((a), (b)); break; \ - case _MM_SHUFFLE(1, 1, 3, 3): ret = _mm_shuffle_ps_1133((a), (b)); break; \ - case _MM_SHUFFLE(2, 0, 1, 0): ret = _mm_shuffle_ps_2010((a), (b)); break; \ - case _MM_SHUFFLE(2, 0, 0, 1): ret = _mm_shuffle_ps_2001((a), (b)); break; \ - case _MM_SHUFFLE(2, 0, 3, 2): ret = _mm_shuffle_ps_2032((a), (b)); break; \ - default: ret = _mm_shuffle_ps_default((a), (b), (imm)); break; \ - } \ - ret; \ -}) - -// Takes the upper 64 bits of a and places it in the low end of the result -// Takes the lower 64 bits of a and places it into the high end of the result. -FORCE_INLINE __m128i _mm_shuffle_epi_1032(__m128i a) -{ - int32x2_t a32 = vget_high_s32(vreinterpretq_s32_m128i(a)); - int32x2_t a10 = vget_low_s32(vreinterpretq_s32_m128i(a)); - return vreinterpretq_m128i_s32(vcombine_s32(a32, a10)); -} - -// takes the lower two 32-bit values from a and swaps them and places in low end of result -// takes the higher two 32 bit values from a and swaps them and places in high end of result. -FORCE_INLINE __m128i _mm_shuffle_epi_2301(__m128i a) -{ - int32x2_t a01 = vrev64_s32(vget_low_s32(vreinterpretq_s32_m128i(a))); - int32x2_t a23 = vrev64_s32(vget_high_s32(vreinterpretq_s32_m128i(a))); - return vreinterpretq_m128i_s32(vcombine_s32(a01, a23)); -} - -// rotates the least significant 32 bits into the most signficant 32 bits, and shifts the rest down -FORCE_INLINE __m128i _mm_shuffle_epi_0321(__m128i a) -{ - return vreinterpretq_m128i_s32(vextq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(a), 1)); -} - -// rotates the most significant 32 bits into the least signficant 32 bits, and shifts the rest up -FORCE_INLINE __m128i _mm_shuffle_epi_2103(__m128i a) -{ - return vreinterpretq_m128i_s32(vextq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(a), 3)); -} - -// gets the lower 64 bits of a, and places it in the upper 64 bits -// gets the lower 64 bits of a and places it in the lower 64 bits -FORCE_INLINE __m128i _mm_shuffle_epi_1010(__m128i a) -{ - int32x2_t a10 = vget_low_s32(vreinterpretq_s32_m128i(a)); - return vreinterpretq_m128i_s32(vcombine_s32(a10, a10)); -} - -// gets the lower 64 bits of a, swaps the 0 and 1 elements, and places it in the lower 64 bits -// gets the lower 64 bits of a, and places it in the upper 64 bits -FORCE_INLINE __m128i _mm_shuffle_epi_1001(__m128i a) -{ - int32x2_t a01 = vrev64_s32(vget_low_s32(vreinterpretq_s32_m128i(a))); - int32x2_t a10 = vget_low_s32(vreinterpretq_s32_m128i(a)); - return vreinterpretq_m128i_s32(vcombine_s32(a01, a10)); -} - -// gets the lower 64 bits of a, swaps the 0 and 1 elements and places it in the upper 64 bits -// gets the lower 64 bits of a, swaps the 0 and 1 elements, and places it in the lower 64 bits -FORCE_INLINE __m128i _mm_shuffle_epi_0101(__m128i a) -{ - int32x2_t a01 = vrev64_s32(vget_low_s32(vreinterpretq_s32_m128i(a))); - return vreinterpretq_m128i_s32(vcombine_s32(a01, a01)); -} - -FORCE_INLINE __m128i _mm_shuffle_epi_2211(__m128i a) -{ - int32x2_t a11 = vdup_lane_s32(vget_low_s32(vreinterpretq_s32_m128i(a)), 1); - int32x2_t a22 = vdup_lane_s32(vget_high_s32(vreinterpretq_s32_m128i(a)), 0); - return vreinterpretq_m128i_s32(vcombine_s32(a11, a22)); -} - -FORCE_INLINE __m128i _mm_shuffle_epi_0122(__m128i a) -{ - int32x2_t a22 = vdup_lane_s32(vget_high_s32(vreinterpretq_s32_m128i(a)), 0); - int32x2_t a01 = vrev64_s32(vget_low_s32(vreinterpretq_s32_m128i(a))); - return vreinterpretq_m128i_s32(vcombine_s32(a22, a01)); -} - -FORCE_INLINE __m128i _mm_shuffle_epi_3332(__m128i a) -{ - int32x2_t a32 = vget_high_s32(vreinterpretq_s32_m128i(a)); - int32x2_t a33 = vdup_lane_s32(vget_high_s32(vreinterpretq_s32_m128i(a)), 1); - return vreinterpretq_m128i_s32(vcombine_s32(a32, a33)); -} - -//FORCE_INLINE __m128i _mm_shuffle_epi32_default(__m128i a, __constrange(0,255) int imm) -#if ENABLE_CPP_VERSION -FORCE_INLINE __m128i _mm_shuffle_epi32_default(__m128i a, __constrange(0,255) int imm) -{ - __m128i ret; - ret[0] = a[imm & 0x3]; - ret[1] = a[(imm >> 2) & 0x3]; - ret[2] = a[(imm >> 4) & 0x03]; - ret[3] = a[(imm >> 6) & 0x03]; - return ret; -} -#else -#define _mm_shuffle_epi32_default(a, imm) \ -({ \ - int32x4_t ret; \ - ret = vmovq_n_s32(vgetq_lane_s32(vreinterpretq_s32_m128i(a), (imm) & 0x3)); \ - ret = vsetq_lane_s32(vgetq_lane_s32(vreinterpretq_s32_m128i(a), ((imm) >> 2) & 0x3), ret, 1); \ - ret = vsetq_lane_s32(vgetq_lane_s32(vreinterpretq_s32_m128i(a), ((imm) >> 4) & 0x3), ret, 2); \ - ret = vsetq_lane_s32(vgetq_lane_s32(vreinterpretq_s32_m128i(a), ((imm) >> 6) & 0x3), ret, 3); \ - vreinterpretq_m128i_s32(ret); \ -}) -#endif - -//FORCE_INLINE __m128i _mm_shuffle_epi32_splat(__m128i a, __constrange(0,255) int imm) -#if defined(__aarch64__) -#define _mm_shuffle_epi32_splat(a, imm) \ -({ \ - vreinterpretq_m128i_s32(vdupq_laneq_s32(vreinterpretq_s32_m128i(a), (imm))); \ -}) -#else -#define _mm_shuffle_epi32_splat(a, imm) \ -({ \ - vreinterpretq_m128i_s32(vdupq_n_s32(vgetq_lane_s32(vreinterpretq_s32_m128i(a), (imm)))); \ -}) -#endif - -// Shuffles the 4 signed or unsigned 32-bit integers in a as specified by imm. https://msdn.microsoft.com/en-us/library/56f67xbk%28v=vs.90%29.aspx -//FORCE_INLINE __m128i _mm_shuffle_epi32(__m128i a, __constrange(0,255) int imm) -#define _mm_shuffle_epi32(a, imm) \ -({ \ - __m128i ret; \ - switch (imm) \ - { \ - case _MM_SHUFFLE(1, 0, 3, 2): ret = _mm_shuffle_epi_1032((a)); break; \ - case _MM_SHUFFLE(2, 3, 0, 1): ret = _mm_shuffle_epi_2301((a)); break; \ - case _MM_SHUFFLE(0, 3, 2, 1): ret = _mm_shuffle_epi_0321((a)); break; \ - case _MM_SHUFFLE(2, 1, 0, 3): ret = _mm_shuffle_epi_2103((a)); break; \ - case _MM_SHUFFLE(1, 0, 1, 0): ret = _mm_shuffle_epi_1010((a)); break; \ - case _MM_SHUFFLE(1, 0, 0, 1): ret = _mm_shuffle_epi_1001((a)); break; \ - case _MM_SHUFFLE(0, 1, 0, 1): ret = _mm_shuffle_epi_0101((a)); break; \ - case _MM_SHUFFLE(2, 2, 1, 1): ret = _mm_shuffle_epi_2211((a)); break; \ - case _MM_SHUFFLE(0, 1, 2, 2): ret = _mm_shuffle_epi_0122((a)); break; \ - case _MM_SHUFFLE(3, 3, 3, 2): ret = _mm_shuffle_epi_3332((a)); break; \ - case _MM_SHUFFLE(0, 0, 0, 0): ret = _mm_shuffle_epi32_splat((a),0); break; \ - case _MM_SHUFFLE(1, 1, 1, 1): ret = _mm_shuffle_epi32_splat((a),1); break; \ - case _MM_SHUFFLE(2, 2, 2, 2): ret = _mm_shuffle_epi32_splat((a),2); break; \ - case _MM_SHUFFLE(3, 3, 3, 3): ret = _mm_shuffle_epi32_splat((a),3); break; \ - default: ret = _mm_shuffle_epi32_default((a), (imm)); break; \ - } \ - ret; \ -}) - -// Shuffles the upper 4 signed or unsigned 16 - bit integers in a as specified by imm. https://msdn.microsoft.com/en-us/library/13ywktbs(v=vs.100).aspx -//FORCE_INLINE __m128i _mm_shufflehi_epi16_function(__m128i a, __constrange(0,255) int imm) -#define _mm_shufflehi_epi16_function(a, imm) \ -({ \ - int16x8_t ret = vreinterpretq_s16_s32(a); \ - int16x4_t highBits = vget_high_s16(ret); \ - ret = vsetq_lane_s16(vget_lane_s16(highBits, (imm) & 0x3), ret, 4); \ - ret = vsetq_lane_s16(vget_lane_s16(highBits, ((imm) >> 2) & 0x3), ret, 5); \ - ret = vsetq_lane_s16(vget_lane_s16(highBits, ((imm) >> 4) & 0x3), ret, 6); \ - ret = vsetq_lane_s16(vget_lane_s16(highBits, ((imm) >> 6) & 0x3), ret, 7); \ - vreinterpretq_s32_s16(ret); \ -}) - -//FORCE_INLINE __m128i _mm_shufflehi_epi16(__m128i a, __constrange(0,255) int imm) -#define _mm_shufflehi_epi16(a, imm) \ - _mm_shufflehi_epi16_function((a), (imm)) - - -// Shifts the 4 signed or unsigned 32-bit integers in a left by count bits while shifting in zeros. : https://msdn.microsoft.com/en-us/library/z2k3bbtb%28v=vs.90%29.aspx -//FORCE_INLINE __m128i _mm_slli_epi32(__m128i a, __constrange(0,255) int imm) -#define _mm_slli_epi32(a, imm) \ -({ \ - __m128i ret; \ - if ((imm) <= 0) {\ - ret = a; \ - } \ - else if ((imm) > 31) { \ - ret = _mm_setzero_si128(); \ - } \ - else { \ - ret = vreinterpretq_m128i_s32(vshlq_n_s32(vreinterpretq_s32_m128i(a), (imm))); \ - } \ - ret; \ -}) - -//Shifts the 4 signed or unsigned 32-bit integers in a right by count bits while shifting in zeros. https://msdn.microsoft.com/en-us/library/w486zcfa(v=vs.100).aspx -//FORCE_INLINE __m128i _mm_srli_epi32(__m128i a, __constrange(0,255) int imm) -#define _mm_srli_epi32(a, imm) \ -({ \ - __m128i ret; \ - if ((imm) <= 0) { \ - ret = a; \ - } \ - else if ((imm)> 31) { \ - ret = _mm_setzero_si128(); \ - } \ - else { \ - ret = vreinterpretq_m128i_u32(vshrq_n_u32(vreinterpretq_u32_m128i(a), (imm))); \ - } \ - ret; \ -}) - -// Shifts the 4 signed 32 - bit integers in a right by count bits while shifting in the sign bit. https://msdn.microsoft.com/en-us/library/z1939387(v=vs.100).aspx -//FORCE_INLINE __m128i _mm_srai_epi32(__m128i a, __constrange(0,255) int imm) -#define _mm_srai_epi32(a, imm) \ -({ \ - __m128i ret; \ - if ((imm) <= 0) { \ - ret = a; \ - } \ - else if ((imm) > 31) { \ - ret = vreinterpretq_m128i_s32(vshrq_n_s32(vreinterpretq_s32_m128i(a), 16)); \ - ret = vreinterpretq_m128i_s32(vshrq_n_s32(vreinterpretq_s32_m128i(ret), 16)); \ - } \ - else { \ - ret = vreinterpretq_m128i_s32(vshrq_n_s32(vreinterpretq_s32_m128i(a), (imm))); \ - } \ - ret; \ -}) - -// Shifts the 128 - bit value in a right by imm bytes while shifting in zeros.imm must be an immediate. https://msdn.microsoft.com/en-us/library/305w28yz(v=vs.100).aspx -//FORCE_INLINE _mm_srli_si128(__m128i a, __constrange(0,255) int imm) -#define _mm_srli_si128(a, imm) \ -({ \ - __m128i ret; \ - if ((imm) <= 0) { \ - ret = a; \ - } \ - else if ((imm) > 15) { \ - ret = _mm_setzero_si128(); \ - } \ - else { \ - ret = vreinterpretq_m128i_s8(vextq_s8(vreinterpretq_s8_m128i(a), vdupq_n_s8(0), (imm))); \ - } \ - ret; \ -}) - -// Shifts the 128-bit value in a left by imm bytes while shifting in zeros. imm must be an immediate. https://msdn.microsoft.com/en-us/library/34d3k2kt(v=vs.100).aspx -//FORCE_INLINE __m128i _mm_slli_si128(__m128i a, __constrange(0,255) int imm) -#define _mm_slli_si128(a, imm) \ -({ \ - __m128i ret; \ - if ((imm) <= 0) { \ - ret = a; \ - } \ - else if ((imm) > 15) { \ - ret = _mm_setzero_si128(); \ - } \ - else { \ - ret = vreinterpretq_m128i_s8(vextq_s8(vdupq_n_s8(0), vreinterpretq_s8_m128i(a), 16 - (imm))); \ - } \ - ret; \ -}) - -// NEON does not provide a version of this function, here is an article about some ways to repro the results. -// http://stackoverflow.com/questions/11870910/sse-mm-movemask-epi8-equivalent-method-for-arm-neon -// Creates a 16-bit mask from the most significant bits of the 16 signed or unsigned 8-bit integers in a and zero extends the upper bits. https://msdn.microsoft.com/en-us/library/vstudio/s090c8fk(v=vs.100).aspx -FORCE_INLINE int _mm_movemask_epi8(__m128i _a) -{ - uint8x16_t input = vreinterpretq_u8_m128i(_a); - static const int8_t __attribute__((aligned(16))) xr[8] = { -7, -6, -5, -4, -3, -2, -1, 0 }; - uint8x8_t mask_and = vdup_n_u8(0x80); - int8x8_t mask_shift = vld1_s8(xr); - - uint8x8_t lo = vget_low_u8(input); - uint8x8_t hi = vget_high_u8(input); - - lo = vand_u8(lo, mask_and); - lo = vshl_u8(lo, mask_shift); - - hi = vand_u8(hi, mask_and); - hi = vshl_u8(hi, mask_shift); - - lo = vpadd_u8(lo, lo); - lo = vpadd_u8(lo, lo); - lo = vpadd_u8(lo, lo); - - hi = vpadd_u8(hi, hi); - hi = vpadd_u8(hi, hi); - hi = vpadd_u8(hi, hi); - - return ((hi[0] << 8) | (lo[0] & 0xFF)); -} - - -// ****************************************** -// Math operations -// ****************************************** - -// Subtracts the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/1zad2k61(v=vs.100).aspx -FORCE_INLINE __m128 _mm_sub_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_f32(vsubq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Subtracts the 4 signed or unsigned 32-bit integers of b from the 4 signed or unsigned 32-bit integers of a. https://msdn.microsoft.com/en-us/library/vstudio/fhh866h0(v=vs.100).aspx -FORCE_INLINE __m128i _mm_sub_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128_f32(vsubq_s32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -FORCE_INLINE __m128i _mm_sub_epi16(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s16(vsubq_s16(vreinterpretq_s16_m128i(a), vreinterpretq_s16_m128i(b))); -} - -// Adds the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/c9848chc(v=vs.100).aspx -FORCE_INLINE __m128 _mm_add_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_f32(vaddq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// adds the scalar single-precision floating point values of a and b. https://msdn.microsoft.com/en-us/library/be94x2y6(v=vs.100).aspx -FORCE_INLINE __m128 _mm_add_ss(__m128 a, __m128 b) -{ - float32_t b0 = vgetq_lane_f32(vreinterpretq_f32_m128(b), 0); - float32x4_t value = vsetq_lane_f32(b0, vdupq_n_f32(0), 0); - //the upper values in the result must be the remnants of . - return vreinterpretq_m128_f32(vaddq_f32(a, value)); -} - -// Adds the 4 signed or unsigned 32-bit integers in a to the 4 signed or unsigned 32-bit integers in b. https://msdn.microsoft.com/en-us/library/vstudio/09xs4fkk(v=vs.100).aspx -FORCE_INLINE __m128i _mm_add_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32(vaddq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b))); -} - -// Adds the 8 signed or unsigned 16-bit integers in a to the 8 signed or unsigned 16-bit integers in b. https://msdn.microsoft.com/en-us/library/fceha5k4(v=vs.100).aspx -FORCE_INLINE __m128i _mm_add_epi16(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s16(vaddq_s16(vreinterpretq_s16_m128i(a), vreinterpretq_s16_m128i(b))); -} - -// Multiplies the 8 signed or unsigned 16-bit integers from a by the 8 signed or unsigned 16-bit integers from b. https://msdn.microsoft.com/en-us/library/vstudio/9ks1472s(v=vs.100).aspx -FORCE_INLINE __m128i _mm_mullo_epi16(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s16(vmulq_s16(vreinterpretq_s16_m128i(a), vreinterpretq_s16_m128i(b))); -} - -// Multiplies the 4 signed or unsigned 32-bit integers from a by the 4 signed or unsigned 32-bit integers from b. https://msdn.microsoft.com/en-us/library/vstudio/bb531409(v=vs.100).aspx -FORCE_INLINE __m128i _mm_mullo_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32(vmulq_s32(vreinterpretq_s32_m128i(a),vreinterpretq_s32_m128i(b))); -} - -// Multiplies the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/22kbk6t9(v=vs.100).aspx -FORCE_INLINE __m128 _mm_mul_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_f32(vmulq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Divides the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/edaw8147(v=vs.100).aspx -FORCE_INLINE __m128 _mm_div_ps(__m128 a, __m128 b) -{ - float32x4_t recip0 = vrecpeq_f32(vreinterpretq_f32_m128(b)); - float32x4_t recip1 = vmulq_f32(recip0, vrecpsq_f32(recip0, vreinterpretq_f32_m128(b))); - return vreinterpretq_m128_f32(vmulq_f32(vreinterpretq_f32_m128(a), recip1)); -} - -// Divides the scalar single-precision floating point value of a by b. https://msdn.microsoft.com/en-us/library/4y73xa49(v=vs.100).aspx -FORCE_INLINE __m128 _mm_div_ss(__m128 a, __m128 b) -{ - float32_t value = vgetq_lane_f32(vreinterpretq_f32_m128(_mm_div_ps(a, b)), 0); - return vreinterpretq_m128_f32(vsetq_lane_f32(value, vreinterpretq_f32_m128(a), 0)); -} - -// This version does additional iterations to improve accuracy. Between 1 and 4 recommended. -// Computes the approximations of reciprocals of the four single-precision, floating-point values of a. https://msdn.microsoft.com/en-us/library/vstudio/796k1tty(v=vs.100).aspx -FORCE_INLINE __m128 recipq_newton(__m128 in, int n) -{ - int i; - float32x4_t recip = vrecpeq_f32(vreinterpretq_f32_m128(in)); - for (i = 0; i < n; ++i) - { - recip = vmulq_f32(recip, vrecpsq_f32(recip, vreinterpretq_f32_m128(in))); - } - return vreinterpretq_m128_f32(recip); -} - -// Computes the approximations of reciprocals of the four single-precision, floating-point values of a. https://msdn.microsoft.com/en-us/library/vstudio/796k1tty(v=vs.100).aspx -FORCE_INLINE __m128 _mm_rcp_ps(__m128 in) -{ - float32x4_t recip = vrecpeq_f32(vreinterpretq_f32_m128(in)); - recip = vmulq_f32(recip, vrecpsq_f32(recip, vreinterpretq_f32_m128(in))); - return vreinterpretq_m128_f32(recip); -} - -// Computes the approximations of square roots of the four single-precision, floating-point values of a. First computes reciprocal square roots and then reciprocals of the four values. https://msdn.microsoft.com/en-us/library/vstudio/8z67bwwk(v=vs.100).aspx -FORCE_INLINE __m128 _mm_sqrt_ps(__m128 in) -{ - float32x4_t recipsq = vrsqrteq_f32(vreinterpretq_f32_m128(in)); - float32x4_t sq = vrecpeq_f32(recipsq); - // ??? use step versions of both sqrt and recip for better accuracy? - return vreinterpretq_m128_f32(sq); -} - -// Computes the approximation of the square root of the scalar single-precision floating point value of in. https://msdn.microsoft.com/en-us/library/ahfsc22d(v=vs.100).aspx -FORCE_INLINE __m128 _mm_sqrt_ss(__m128 in) -{ - float32_t value = vgetq_lane_f32(vreinterpretq_f32_m128(_mm_sqrt_ps(in)), 0); - return vreinterpretq_m128_f32(vsetq_lane_f32(value, vreinterpretq_f32_m128(in), 0)); -} - -// Computes the approximations of the reciprocal square roots of the four single-precision floating point values of in. https://msdn.microsoft.com/en-us/library/22hfsh53(v=vs.100).aspx -FORCE_INLINE __m128 _mm_rsqrt_ps(__m128 in) -{ - return vreinterpretq_m128_f32(vrsqrteq_f32(vreinterpretq_f32_m128(in))); -} - -// Computes the maximums of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/ff5d607a(v=vs.100).aspx -FORCE_INLINE __m128 _mm_max_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_f32(vmaxq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Computes the minima of the four single-precision, floating-point values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/wh13kadz(v=vs.100).aspx -FORCE_INLINE __m128 _mm_min_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_f32(vminq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Computes the maximum of the two lower scalar single-precision floating point values of a and b. https://msdn.microsoft.com/en-us/library/s6db5esz(v=vs.100).aspx -FORCE_INLINE __m128 _mm_max_ss(__m128 a, __m128 b) -{ - float32_t value = vgetq_lane_f32(vmaxq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - return vreinterpretq_m128_f32(vsetq_lane_f32(value, vreinterpretq_f32_m128(a), 0)); -} - -// Computes the minimum of the two lower scalar single-precision floating point values of a and b. https://msdn.microsoft.com/en-us/library/0a9y7xaa(v=vs.100).aspx -FORCE_INLINE __m128 _mm_min_ss(__m128 a, __m128 b) -{ - float32_t value = vgetq_lane_f32(vminq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - return vreinterpretq_m128_f32(vsetq_lane_f32(value, vreinterpretq_f32_m128(a), 0)); -} - -// Computes the pairwise minima of the 8 signed 16-bit integers from a and the 8 signed 16-bit integers from b. https://msdn.microsoft.com/en-us/library/vstudio/6te997ew(v=vs.100).aspx -FORCE_INLINE __m128i _mm_min_epi16(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s16(vminq_s16(vreinterpretq_s16_m128i(a), vreinterpretq_s16_m128i(b))); -} - -// epi versions of min/max -// Computes the pariwise maximums of the four signed 32-bit integer values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/bb514055(v=vs.100).aspx -FORCE_INLINE __m128i _mm_max_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32(vmaxq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b))); -} - -// Computes the pariwise minima of the four signed 32-bit integer values of a and b. https://msdn.microsoft.com/en-us/library/vstudio/bb531476(v=vs.100).aspx -FORCE_INLINE __m128i _mm_min_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s32(vminq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b))); -} - -// Multiplies the 8 signed 16-bit integers from a by the 8 signed 16-bit integers from b. https://msdn.microsoft.com/en-us/library/vstudio/59hddw1d(v=vs.100).aspx -FORCE_INLINE __m128i _mm_mulhi_epi16(__m128i a, __m128i b) -{ - /* apoty: issue with large values because of result saturation */ - //int16x8_t ret = vqdmulhq_s16(vreinterpretq_s16_m128i(a), vreinterpretq_s16_m128i(b)); /* =2*a*b */ - //return vreinterpretq_m128i_s16(vshrq_n_s16(ret, 1)); - int16x4_t a3210 = vget_low_s16(vreinterpretq_s16_m128i(a)); - int16x4_t b3210 = vget_low_s16(vreinterpretq_s16_m128i(b)); - int32x4_t ab3210 = vmull_s16(a3210, b3210); /* 3333222211110000 */ - int16x4_t a7654 = vget_high_s16(vreinterpretq_s16_m128i(a)); - int16x4_t b7654 = vget_high_s16(vreinterpretq_s16_m128i(b)); - int32x4_t ab7654 = vmull_s16(a7654, b7654); /* 7777666655554444 */ - uint16x8x2_t r = vuzpq_u16(vreinterpretq_u16_s32(ab3210), vreinterpretq_u16_s32(ab7654)); - return vreinterpretq_m128i_u16(r.val[1]); -} - -// Computes pairwise add of each argument as single-precision, floating-point values a and b. -//https://msdn.microsoft.com/en-us/library/yd9wecaa.aspx -FORCE_INLINE __m128 _mm_hadd_ps(__m128 a, __m128 b ) -{ -#if defined(__aarch64__) - return vreinterpretq_m128_f32(vpaddq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); //AArch64 -#else - float32x2_t a10 = vget_low_f32(vreinterpretq_f32_m128(a)); - float32x2_t a32 = vget_high_f32(vreinterpretq_f32_m128(a)); - float32x2_t b10 = vget_low_f32(vreinterpretq_f32_m128(b)); - float32x2_t b32 = vget_high_f32(vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_f32(vcombine_f32(vpadd_f32(a10, a32), vpadd_f32(b10, b32))); -#endif -} - -// ****************************************** -// Compare operations -// ****************************************** - -// Compares for less than https://msdn.microsoft.com/en-us/library/vstudio/f330yhc8(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmplt_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32(vcltq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Compares for greater than. https://msdn.microsoft.com/en-us/library/vstudio/11dy102s(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmpgt_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32(vcgtq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Compares for greater than or equal. https://msdn.microsoft.com/en-us/library/vstudio/fs813y2t(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmpge_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32(vcgeq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Compares for less than or equal. https://msdn.microsoft.com/en-us/library/vstudio/1s75w83z(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmple_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32(vcleq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Compares for equality. https://msdn.microsoft.com/en-us/library/vstudio/36aectz5(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cmpeq_ps(__m128 a, __m128 b) -{ - return vreinterpretq_m128_u32(vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); -} - -// Compares the 4 signed 32-bit integers in a and the 4 signed 32-bit integers in b for less than. https://msdn.microsoft.com/en-us/library/vstudio/4ak0bf5d(v=vs.100).aspx -FORCE_INLINE __m128i _mm_cmplt_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_u32(vcltq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b))); -} - -// Compares the 4 signed 32-bit integers in a and the 4 signed 32-bit integers in b for greater than. https://msdn.microsoft.com/en-us/library/vstudio/1s9f2z0y(v=vs.100).aspx -FORCE_INLINE __m128i _mm_cmpgt_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_u32(vcgtq_s32(vreinterpretq_s32_m128i(a), vreinterpretq_s32_m128i(b))); -} - -// Compares the four 32-bit floats in a and b to check if any values are NaN. Ordered compare between each value returns true for "orderable" and false for "not orderable" (NaN). https://msdn.microsoft.com/en-us/library/vstudio/0h9w00fx(v=vs.100).aspx -// see also: -// http://stackoverflow.com/questions/8627331/what-does-ordered-unordered-comparison-mean -// http://stackoverflow.com/questions/29349621/neon-isnanval-intrinsics -FORCE_INLINE __m128 _mm_cmpord_ps(__m128 a, __m128 b ) -{ - // Note: NEON does not have ordered compare builtin - // Need to compare a eq a and b eq b to check for NaN - // Do AND of results to get final - uint32x4_t ceqaa = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t ceqbb = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - return vreinterpretq_m128_u32(vandq_u32(ceqaa, ceqbb)); -} - -// Compares the lower single-precision floating point scalar values of a and b using a less than operation. : https://msdn.microsoft.com/en-us/library/2kwe606b(v=vs.90).aspx -// Important note!! The documentation on MSDN is incorrect! If either of the values is a NAN the docs say you will get a one, but in fact, it will return a zero!! -FORCE_INLINE int _mm_comilt_ss(__m128 a, __m128 b) -{ - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_lt_b = vcltq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_lt_b), 0) != 0) ? 1 : 0; -} - -// Compares the lower single-precision floating point scalar values of a and b using a greater than operation. : https://msdn.microsoft.com/en-us/library/b0738e0t(v=vs.100).aspx -FORCE_INLINE int _mm_comigt_ss(__m128 a, __m128 b) -{ - //return vgetq_lane_u32(vcgtq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_gt_b = vcgtq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_gt_b), 0) != 0) ? 1 : 0; -} - -// Compares the lower single-precision floating point scalar values of a and b using a less than or equal operation. : https://msdn.microsoft.com/en-us/library/1w4t7c57(v=vs.90).aspx -FORCE_INLINE int _mm_comile_ss(__m128 a, __m128 b) -{ - //return vgetq_lane_u32(vcleq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_le_b = vcleq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_le_b), 0) != 0) ? 1 : 0; -} - -// Compares the lower single-precision floating point scalar values of a and b using a greater than or equal operation. : https://msdn.microsoft.com/en-us/library/8t80des6(v=vs.100).aspx -FORCE_INLINE int _mm_comige_ss(__m128 a, __m128 b) -{ - //return vgetq_lane_u32(vcgeq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_ge_b = vcgeq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_ge_b), 0) != 0) ? 1 : 0; -} - -// Compares the lower single-precision floating point scalar values of a and b using an equality operation. : https://msdn.microsoft.com/en-us/library/93yx2h2b(v=vs.100).aspx -FORCE_INLINE int _mm_comieq_ss(__m128 a, __m128 b) -{ - //return vgetq_lane_u32(vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_eq_b = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_eq_b), 0) != 0) ? 1 : 0; -} - -// Compares the lower single-precision floating point scalar values of a and b using an inequality operation. : https://msdn.microsoft.com/en-us/library/bafh5e0a(v=vs.90).aspx -FORCE_INLINE int _mm_comineq_ss(__m128 a, __m128 b) -{ - //return !vgetq_lane_u32(vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b)), 0); - uint32x4_t a_not_nan = vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(a)); - uint32x4_t b_not_nan = vceqq_f32(vreinterpretq_f32_m128(b), vreinterpretq_f32_m128(b)); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_neq_b = vmvnq_u32(vceqq_f32(vreinterpretq_f32_m128(a), vreinterpretq_f32_m128(b))); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_neq_b), 0) != 0) ? 1 : 0; -} - -// according to the documentation, these intrinsics behave the same as the non-'u' versions. We'll just alias them here. -#define _mm_ucomilt_ss _mm_comilt_ss -#define _mm_ucomile_ss _mm_comile_ss -#define _mm_ucomigt_ss _mm_comigt_ss -#define _mm_ucomige_ss _mm_comige_ss -#define _mm_ucomieq_ss _mm_comieq_ss -#define _mm_ucomineq_ss _mm_comineq_ss - -// ****************************************** -// Conversions -// ****************************************** - -// Converts the four single-precision, floating-point values of a to signed 32-bit integer values using truncate. https://msdn.microsoft.com/en-us/library/vstudio/1h005y6x(v=vs.100).aspx -FORCE_INLINE __m128i _mm_cvttps_epi32(__m128 a) -{ - return vreinterpretq_m128i_s32(vcvtq_s32_f32(vreinterpretq_f32_m128(a))); -} - -// Converts the four signed 32-bit integer values of a to single-precision, floating-point values https://msdn.microsoft.com/en-us/library/vstudio/36bwxcx5(v=vs.100).aspx -FORCE_INLINE __m128 _mm_cvtepi32_ps(__m128i a) -{ - return vreinterpretq_m128_f32(vcvtq_f32_s32(vreinterpretq_s32_m128i(a))); -} - -// Converts the four unsigned 8-bit integers in the lower 32 bits to four unsigned 32-bit integers. https://msdn.microsoft.com/en-us/library/bb531467%28v=vs.100%29.aspx -FORCE_INLINE __m128i _mm_cvtepu8_epi32(__m128i a) -{ - uint8x16_t u8x16 = vreinterpretq_u8_s32(a); /* xxxx xxxx xxxx DCBA */ - uint16x8_t u16x8 = vmovl_u8(vget_low_u8(u8x16)); /* 0x0x 0x0x 0D0C 0B0A */ - uint32x4_t u32x4 = vmovl_u16(vget_low_u16(u16x8)); /* 000D 000C 000B 000A */ - return vreinterpretq_s32_u32(u32x4); -} - -// Converts the four signed 16-bit integers in the lower 64 bits to four signed 32-bit integers. https://msdn.microsoft.com/en-us/library/bb514079%28v=vs.100%29.aspx -FORCE_INLINE __m128i _mm_cvtepi16_epi32(__m128i a) -{ - return vreinterpretq_m128i_s32(vmovl_s16(vget_low_s16(vreinterpretq_s16_m128i(a)))); -} - -// Converts the four single-precision, floating-point values of a to signed 32-bit integer values. https://msdn.microsoft.com/en-us/library/vstudio/xdc42k5e(v=vs.100).aspx -// *NOTE*. The default rounding mode on SSE is 'round to even', which ArmV7 does not support! -// It is supported on ARMv8 however. -FORCE_INLINE __m128i _mm_cvtps_epi32(__m128 a) -{ -#if defined(__aarch64__) - return vcvtnq_s32_f32(a); -#else - uint32x4_t signmask = vdupq_n_u32(0x80000000); - float32x4_t half = vbslq_f32(signmask, vreinterpretq_f32_m128(a), vdupq_n_f32(0.5f)); /* +/- 0.5 */ - int32x4_t r_normal = vcvtq_s32_f32(vaddq_f32(vreinterpretq_f32_m128(a), half)); /* round to integer: [a + 0.5]*/ - int32x4_t r_trunc = vcvtq_s32_f32(vreinterpretq_f32_m128(a)); /* truncate to integer: [a] */ - int32x4_t plusone = vreinterpretq_s32_u32(vshrq_n_u32(vreinterpretq_u32_s32(vnegq_s32(r_trunc)), 31)); /* 1 or 0 */ - int32x4_t r_even = vbicq_s32(vaddq_s32(r_trunc, plusone), vdupq_n_s32(1)); /* ([a] + {0,1}) & ~1 */ - float32x4_t delta = vsubq_f32(vreinterpretq_f32_m128(a), vcvtq_f32_s32(r_trunc)); /* compute delta: delta = (a - [a]) */ - uint32x4_t is_delta_half = vceqq_f32(delta, half); /* delta == +/- 0.5 */ - return vreinterpretq_m128i_s32(vbslq_s32(is_delta_half, r_even, r_normal)); -#endif -} - -// Moves the least significant 32 bits of a to a 32-bit integer. https://msdn.microsoft.com/en-us/library/5z7a9642%28v=vs.90%29.aspx -FORCE_INLINE int _mm_cvtsi128_si32(__m128i a) -{ - return vgetq_lane_s32(vreinterpretq_s32_m128i(a), 0); -} - -// Moves 32-bit integer a to the least significant 32 bits of an __m128 object, zero extending the upper bits. https://msdn.microsoft.com/en-us/library/ct3539ha%28v=vs.90%29.aspx -FORCE_INLINE __m128i _mm_cvtsi32_si128(int a) -{ - return vreinterpretq_m128i_s32(vsetq_lane_s32(a, vdupq_n_s32(0), 0)); -} - - -// Applies a type cast to reinterpret four 32-bit floating point values passed in as a 128-bit parameter as packed 32-bit integers. https://msdn.microsoft.com/en-us/library/bb514099.aspx -FORCE_INLINE __m128i _mm_castps_si128(__m128 a) -{ - return vreinterpretq_m128i_s32(vreinterpretq_s32_m128(a)); -} - -// Applies a type cast to reinterpret four 32-bit integers passed in as a 128-bit parameter as packed 32-bit floating point values. https://msdn.microsoft.com/en-us/library/bb514029.aspx -FORCE_INLINE __m128 _mm_castsi128_ps(__m128i a) -{ - return vreinterpretq_m128_s32(vreinterpretq_s32_m128i(a)); -} - -// Loads 128-bit value. : https://msdn.microsoft.com/en-us/library/atzzad1h(v=vs.80).aspx -FORCE_INLINE __m128i _mm_load_si128(const __m128i *p) -{ - return vreinterpretq_m128i_s32(vld1q_s32((int32_t *)p)); -} - -// ****************************************** -// Miscellaneous Operations -// ****************************************** - -// Packs the 16 signed 16-bit integers from a and b into 8-bit integers and saturates. https://msdn.microsoft.com/en-us/library/k4y4f7w5%28v=vs.90%29.aspx -FORCE_INLINE __m128i _mm_packs_epi16(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s8(vcombine_s8(vqmovn_s16(vreinterpretq_s16_m128i(a)), vqmovn_s16(vreinterpretq_s16_m128i(b)))); -} - -// Packs the 16 signed 16 - bit integers from a and b into 8 - bit unsigned integers and saturates. https://msdn.microsoft.com/en-us/library/07ad1wx4(v=vs.100).aspx -FORCE_INLINE __m128i _mm_packus_epi16(const __m128i a, const __m128i b) -{ - return vreinterpretq_m128i_u8(vcombine_u8(vqmovun_s16(vreinterpretq_s16_m128i(a)), vqmovun_s16(vreinterpretq_s16_m128i(b)))); -} - -// Packs the 8 signed 32-bit integers from a and b into signed 16-bit integers and saturates. https://msdn.microsoft.com/en-us/library/393t56f9%28v=vs.90%29.aspx -FORCE_INLINE __m128i _mm_packs_epi32(__m128i a, __m128i b) -{ - return vreinterpretq_m128i_s16(vcombine_s16(vqmovn_s32(vreinterpretq_s32_m128i(a)), vqmovn_s32(vreinterpretq_s32_m128i(b)))); -} - -// Interleaves the lower 8 signed or unsigned 8-bit integers in a with the lower 8 signed or unsigned 8-bit integers in b. https://msdn.microsoft.com/en-us/library/xf7k860c%28v=vs.90%29.aspx -FORCE_INLINE __m128i _mm_unpacklo_epi8(__m128i a, __m128i b) -{ - int8x8_t a1 = vreinterpret_s8_s16(vget_low_s16(vreinterpretq_s16_m128i(a))); - int8x8_t b1 = vreinterpret_s8_s16(vget_low_s16(vreinterpretq_s16_m128i(b))); - int8x8x2_t result = vzip_s8(a1, b1); - return vreinterpretq_m128i_s8(vcombine_s8(result.val[0], result.val[1])); -} - -// Interleaves the lower 4 signed or unsigned 16-bit integers in a with the lower 4 signed or unsigned 16-bit integers in b. https://msdn.microsoft.com/en-us/library/btxb17bw%28v=vs.90%29.aspx -FORCE_INLINE __m128i _mm_unpacklo_epi16(__m128i a, __m128i b) -{ - int16x4_t a1 = vget_low_s16(vreinterpretq_s16_m128i(a)); - int16x4_t b1 = vget_low_s16(vreinterpretq_s16_m128i(b)); - int16x4x2_t result = vzip_s16(a1, b1); - return vreinterpretq_m128i_s16(vcombine_s16(result.val[0], result.val[1])); -} - -// Interleaves the lower 2 signed or unsigned 32 - bit integers in a with the lower 2 signed or unsigned 32 - bit integers in b. https://msdn.microsoft.com/en-us/library/x8atst9d(v=vs.100).aspx -FORCE_INLINE __m128i _mm_unpacklo_epi32(__m128i a, __m128i b) -{ - int32x2_t a1 = vget_low_s32(vreinterpretq_s32_m128i(a)); - int32x2_t b1 = vget_low_s32(vreinterpretq_s32_m128i(b)); - int32x2x2_t result = vzip_s32(a1, b1); - return vreinterpretq_m128i_s32(vcombine_s32(result.val[0], result.val[1])); -} - -// Selects and interleaves the lower two single-precision, floating-point values from a and b. https://msdn.microsoft.com/en-us/library/25st103b%28v=vs.90%29.aspx -FORCE_INLINE __m128 _mm_unpacklo_ps(__m128 a, __m128 b) -{ - float32x2_t a1 = vget_low_f32(vreinterpretq_f32_m128(a)); - float32x2_t b1 = vget_low_f32(vreinterpretq_f32_m128(b)); - float32x2x2_t result = vzip_f32(a1, b1); - return vreinterpretq_m128_f32(vcombine_f32(result.val[0], result.val[1])); -} - -// Selects and interleaves the upper two single-precision, floating-point values from a and b. https://msdn.microsoft.com/en-us/library/skccxx7d%28v=vs.90%29.aspx -FORCE_INLINE __m128 _mm_unpackhi_ps(__m128 a, __m128 b) -{ - float32x2_t a1 = vget_high_f32(vreinterpretq_f32_m128(a)); - float32x2_t b1 = vget_high_f32(vreinterpretq_f32_m128(b)); - float32x2x2_t result = vzip_f32(a1, b1); - return vreinterpretq_m128_f32(vcombine_f32(result.val[0], result.val[1])); -} - -// Interleaves the upper 8 signed or unsigned 8-bit integers in a with the upper 8 signed or unsigned 8-bit integers in b. https://msdn.microsoft.com/en-us/library/t5h7783k(v=vs.100).aspx -FORCE_INLINE __m128i _mm_unpackhi_epi8(__m128i a, __m128i b) -{ - int8x8_t a1 = vreinterpret_s8_s16(vget_high_s16(vreinterpretq_s16_m128i(a))); - int8x8_t b1 = vreinterpret_s8_s16(vget_high_s16(vreinterpretq_s16_m128i(b))); - int8x8x2_t result = vzip_s8(a1, b1); - return vreinterpretq_m128i_s8(vcombine_s8(result.val[0], result.val[1])); -} - -// Interleaves the upper 4 signed or unsigned 16-bit integers in a with the upper 4 signed or unsigned 16-bit integers in b. https://msdn.microsoft.com/en-us/library/03196cz7(v=vs.100).aspx -FORCE_INLINE __m128i _mm_unpackhi_epi16(__m128i a, __m128i b) -{ - int16x4_t a1 = vget_high_s16(vreinterpretq_s16_m128i(a)); - int16x4_t b1 = vget_high_s16(vreinterpretq_s16_m128i(b)); - int16x4x2_t result = vzip_s16(a1, b1); - return vreinterpretq_m128i_s16(vcombine_s16(result.val[0], result.val[1])); -} - -// Interleaves the upper 2 signed or unsigned 32-bit integers in a with the upper 2 signed or unsigned 32-bit integers in b. https://msdn.microsoft.com/en-us/library/65sa7cbs(v=vs.100).aspx -FORCE_INLINE __m128i _mm_unpackhi_epi32(__m128i a, __m128i b) -{ - int32x2_t a1 = vget_high_s32(vreinterpretq_s32_m128i(a)); - int32x2_t b1 = vget_high_s32(vreinterpretq_s32_m128i(b)); - int32x2x2_t result = vzip_s32(a1, b1); - return vreinterpretq_m128i_s32(vcombine_s32(result.val[0], result.val[1])); -} - -// Extracts the selected signed or unsigned 16-bit integer from a and zero extends. https://msdn.microsoft.com/en-us/library/6dceta0c(v=vs.100).aspx -//FORCE_INLINE int _mm_extract_epi16(__m128i a, __constrange(0,8) int imm) -#define _mm_extract_epi16(a, imm) \ -({ \ - (vgetq_lane_s16(vreinterpretq_s16_m128i(a), (imm)) & 0x0000ffffUL); \ -}) - -// Inserts the least significant 16 bits of b into the selected 16-bit integer of a. https://msdn.microsoft.com/en-us/library/kaze8hz1%28v=vs.100%29.aspx -//FORCE_INLINE __m128i _mm_insert_epi16(__m128i a, const int b, __constrange(0,8) int imm) -#define _mm_insert_epi16(a, b, imm) \ -({ \ - vreinterpretq_m128i_s16(vsetq_lane_s16((b), vreinterpretq_s16_m128i(a), (imm))); \ -}) - -// ****************************************** -// Streaming Extensions -// ****************************************** - -// Guarantees that every preceding store is globally visible before any subsequent store. https://msdn.microsoft.com/en-us/library/5h2w73d1%28v=vs.90%29.aspx -FORCE_INLINE void _mm_sfence(void) -{ - __sync_synchronize(); -} - -// Stores the data in a to the address p without polluting the caches. If the cache line containing address p is already in the cache, the cache will be updated.Address p must be 16 - byte aligned. https://msdn.microsoft.com/en-us/library/ba08y07y%28v=vs.90%29.aspx -FORCE_INLINE void _mm_stream_si128(__m128i *p, __m128i a) -{ - *p = a; -} - -// Cache line containing p is flushed and invalidated from all caches in the coherency domain. : https://msdn.microsoft.com/en-us/library/ba08y07y(v=vs.100).aspx -FORCE_INLINE void _mm_clflush(void const*p) -{ - // no corollary for Neon? -} - -#if defined(__GNUC__) || defined(__clang__) -# pragma pop_macro("ALIGN_STRUCT") -# pragma pop_macro("FORCE_INLINE") -#endif - -#endif diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template.inc deleted file mode 100644 index 40c7874d28..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template.inc +++ /dev/null @@ -1,279 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightR_soft_aes_template_part1) -PUBLIC FN_PREFIX(CryptonightR_soft_aes_template_mainloop) -PUBLIC FN_PREFIX(CryptonightR_soft_aes_template_part2) -PUBLIC FN_PREFIX(CryptonightR_soft_aes_template_part3) -PUBLIC FN_PREFIX(CryptonightR_soft_aes_template_end) - -ALIGN(64) -FN_PREFIX(CryptonightR_soft_aes_template_part1): - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movq xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movq xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movq xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movq xmm10, QWORD PTR [r10+96] - movq xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movq xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movq xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -FN_PREFIX(CryptonightR_soft_aes_template_mainloop): - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movq xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movq xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movq r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - pxor xmm6, xmm1 - pxor xmm6, xmm0 - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movq rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movq rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - movaps xmm0, xmm5 - psrldq xmm0, 8 - movd r9d, xmm0 - -FN_PREFIX(CryptonightR_soft_aes_template_part2): - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov edi, edi - shl rbp, 32 - or rbp, rdi - xor r8, rbp - - mov ebx, ebx - shl rsi, 32 - or rsi, rbx - xor QWORD PTR [rsp+320], rsi - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm1 - paddq xmm1, xmm7 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm6, xmm0 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne FN_PREFIX(CryptonightR_soft_aes_template_mainloop) - -FN_PREFIX(CryptonightR_soft_aes_template_part3): - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -FN_PREFIX(CryptonightR_soft_aes_template_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template_win.inc deleted file mode 100644 index d771f69cff..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_soft_aes_template_win.inc +++ /dev/null @@ -1,279 +0,0 @@ -PUBLIC CryptonightR_soft_aes_template_part1 -PUBLIC CryptonightR_soft_aes_template_mainloop -PUBLIC CryptonightR_soft_aes_template_part2 -PUBLIC CryptonightR_soft_aes_template_part3 -PUBLIC CryptonightR_soft_aes_template_end - -ALIGN(64) -CryptonightR_soft_aes_template_part1: - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movq xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movq xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movq xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movq xmm10, QWORD PTR [r10+96] - movq xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movq xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movq xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -CryptonightR_soft_aes_template_mainloop: - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movq xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movq xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movq r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - pxor xmm6, xmm1 - pxor xmm6, xmm0 - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movq rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movq rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - movaps xmm0, xmm5 - psrldq xmm0, 8 - movd r9d, xmm0 - -CryptonightR_soft_aes_template_part2: - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov edi, edi - shl rbp, 32 - or rbp, rdi - xor r8, rbp - - mov ebx, ebx - shl rsi, 32 - or rsi, rbx - xor QWORD PTR [rsp+320], rsi - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm1 - paddq xmm1, xmm7 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm6, xmm0 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne CryptonightR_soft_aes_template_mainloop - -CryptonightR_soft_aes_template_part3: - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -CryptonightR_soft_aes_template_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.S b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.S deleted file mode 100644 index d2974d1605..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.S +++ /dev/null @@ -1,1595 +0,0 @@ -#ifdef __APPLE__ -# define ALIGN(x) .align 6 -#else -# define ALIGN(x) .align 64 -#endif -.intel_syntax noprefix -#ifdef __APPLE__ -# define FN_PREFIX(fn) _ ## fn -.text -#else -# define FN_PREFIX(fn) fn -.section .text -#endif - -#define PUBLIC .global - -PUBLIC FN_PREFIX(CryptonightR_instruction0) -PUBLIC FN_PREFIX(CryptonightR_instruction1) -PUBLIC FN_PREFIX(CryptonightR_instruction2) -PUBLIC FN_PREFIX(CryptonightR_instruction3) -PUBLIC FN_PREFIX(CryptonightR_instruction4) -PUBLIC FN_PREFIX(CryptonightR_instruction5) -PUBLIC FN_PREFIX(CryptonightR_instruction6) -PUBLIC FN_PREFIX(CryptonightR_instruction7) -PUBLIC FN_PREFIX(CryptonightR_instruction8) -PUBLIC FN_PREFIX(CryptonightR_instruction9) -PUBLIC FN_PREFIX(CryptonightR_instruction10) -PUBLIC FN_PREFIX(CryptonightR_instruction11) -PUBLIC FN_PREFIX(CryptonightR_instruction12) -PUBLIC FN_PREFIX(CryptonightR_instruction13) -PUBLIC FN_PREFIX(CryptonightR_instruction14) -PUBLIC FN_PREFIX(CryptonightR_instruction15) -PUBLIC FN_PREFIX(CryptonightR_instruction16) -PUBLIC FN_PREFIX(CryptonightR_instruction17) -PUBLIC FN_PREFIX(CryptonightR_instruction18) -PUBLIC FN_PREFIX(CryptonightR_instruction19) -PUBLIC FN_PREFIX(CryptonightR_instruction20) -PUBLIC FN_PREFIX(CryptonightR_instruction21) -PUBLIC FN_PREFIX(CryptonightR_instruction22) -PUBLIC FN_PREFIX(CryptonightR_instruction23) -PUBLIC FN_PREFIX(CryptonightR_instruction24) -PUBLIC FN_PREFIX(CryptonightR_instruction25) -PUBLIC FN_PREFIX(CryptonightR_instruction26) -PUBLIC FN_PREFIX(CryptonightR_instruction27) -PUBLIC FN_PREFIX(CryptonightR_instruction28) -PUBLIC FN_PREFIX(CryptonightR_instruction29) -PUBLIC FN_PREFIX(CryptonightR_instruction30) -PUBLIC FN_PREFIX(CryptonightR_instruction31) -PUBLIC FN_PREFIX(CryptonightR_instruction32) -PUBLIC FN_PREFIX(CryptonightR_instruction33) -PUBLIC FN_PREFIX(CryptonightR_instruction34) -PUBLIC FN_PREFIX(CryptonightR_instruction35) -PUBLIC FN_PREFIX(CryptonightR_instruction36) -PUBLIC FN_PREFIX(CryptonightR_instruction37) -PUBLIC FN_PREFIX(CryptonightR_instruction38) -PUBLIC FN_PREFIX(CryptonightR_instruction39) -PUBLIC FN_PREFIX(CryptonightR_instruction40) -PUBLIC FN_PREFIX(CryptonightR_instruction41) -PUBLIC FN_PREFIX(CryptonightR_instruction42) -PUBLIC FN_PREFIX(CryptonightR_instruction43) -PUBLIC FN_PREFIX(CryptonightR_instruction44) -PUBLIC FN_PREFIX(CryptonightR_instruction45) -PUBLIC FN_PREFIX(CryptonightR_instruction46) -PUBLIC FN_PREFIX(CryptonightR_instruction47) -PUBLIC FN_PREFIX(CryptonightR_instruction48) -PUBLIC FN_PREFIX(CryptonightR_instruction49) -PUBLIC FN_PREFIX(CryptonightR_instruction50) -PUBLIC FN_PREFIX(CryptonightR_instruction51) -PUBLIC FN_PREFIX(CryptonightR_instruction52) -PUBLIC FN_PREFIX(CryptonightR_instruction53) -PUBLIC FN_PREFIX(CryptonightR_instruction54) -PUBLIC FN_PREFIX(CryptonightR_instruction55) -PUBLIC FN_PREFIX(CryptonightR_instruction56) -PUBLIC FN_PREFIX(CryptonightR_instruction57) -PUBLIC FN_PREFIX(CryptonightR_instruction58) -PUBLIC FN_PREFIX(CryptonightR_instruction59) -PUBLIC FN_PREFIX(CryptonightR_instruction60) -PUBLIC FN_PREFIX(CryptonightR_instruction61) -PUBLIC FN_PREFIX(CryptonightR_instruction62) -PUBLIC FN_PREFIX(CryptonightR_instruction63) -PUBLIC FN_PREFIX(CryptonightR_instruction64) -PUBLIC FN_PREFIX(CryptonightR_instruction65) -PUBLIC FN_PREFIX(CryptonightR_instruction66) -PUBLIC FN_PREFIX(CryptonightR_instruction67) -PUBLIC FN_PREFIX(CryptonightR_instruction68) -PUBLIC FN_PREFIX(CryptonightR_instruction69) -PUBLIC FN_PREFIX(CryptonightR_instruction70) -PUBLIC FN_PREFIX(CryptonightR_instruction71) -PUBLIC FN_PREFIX(CryptonightR_instruction72) -PUBLIC FN_PREFIX(CryptonightR_instruction73) -PUBLIC FN_PREFIX(CryptonightR_instruction74) -PUBLIC FN_PREFIX(CryptonightR_instruction75) -PUBLIC FN_PREFIX(CryptonightR_instruction76) -PUBLIC FN_PREFIX(CryptonightR_instruction77) -PUBLIC FN_PREFIX(CryptonightR_instruction78) -PUBLIC FN_PREFIX(CryptonightR_instruction79) -PUBLIC FN_PREFIX(CryptonightR_instruction80) -PUBLIC FN_PREFIX(CryptonightR_instruction81) -PUBLIC FN_PREFIX(CryptonightR_instruction82) -PUBLIC FN_PREFIX(CryptonightR_instruction83) -PUBLIC FN_PREFIX(CryptonightR_instruction84) -PUBLIC FN_PREFIX(CryptonightR_instruction85) -PUBLIC FN_PREFIX(CryptonightR_instruction86) -PUBLIC FN_PREFIX(CryptonightR_instruction87) -PUBLIC FN_PREFIX(CryptonightR_instruction88) -PUBLIC FN_PREFIX(CryptonightR_instruction89) -PUBLIC FN_PREFIX(CryptonightR_instruction90) -PUBLIC FN_PREFIX(CryptonightR_instruction91) -PUBLIC FN_PREFIX(CryptonightR_instruction92) -PUBLIC FN_PREFIX(CryptonightR_instruction93) -PUBLIC FN_PREFIX(CryptonightR_instruction94) -PUBLIC FN_PREFIX(CryptonightR_instruction95) -PUBLIC FN_PREFIX(CryptonightR_instruction96) -PUBLIC FN_PREFIX(CryptonightR_instruction97) -PUBLIC FN_PREFIX(CryptonightR_instruction98) -PUBLIC FN_PREFIX(CryptonightR_instruction99) -PUBLIC FN_PREFIX(CryptonightR_instruction100) -PUBLIC FN_PREFIX(CryptonightR_instruction101) -PUBLIC FN_PREFIX(CryptonightR_instruction102) -PUBLIC FN_PREFIX(CryptonightR_instruction103) -PUBLIC FN_PREFIX(CryptonightR_instruction104) -PUBLIC FN_PREFIX(CryptonightR_instruction105) -PUBLIC FN_PREFIX(CryptonightR_instruction106) -PUBLIC FN_PREFIX(CryptonightR_instruction107) -PUBLIC FN_PREFIX(CryptonightR_instruction108) -PUBLIC FN_PREFIX(CryptonightR_instruction109) -PUBLIC FN_PREFIX(CryptonightR_instruction110) -PUBLIC FN_PREFIX(CryptonightR_instruction111) -PUBLIC FN_PREFIX(CryptonightR_instruction112) -PUBLIC FN_PREFIX(CryptonightR_instruction113) -PUBLIC FN_PREFIX(CryptonightR_instruction114) -PUBLIC FN_PREFIX(CryptonightR_instruction115) -PUBLIC FN_PREFIX(CryptonightR_instruction116) -PUBLIC FN_PREFIX(CryptonightR_instruction117) -PUBLIC FN_PREFIX(CryptonightR_instruction118) -PUBLIC FN_PREFIX(CryptonightR_instruction119) -PUBLIC FN_PREFIX(CryptonightR_instruction120) -PUBLIC FN_PREFIX(CryptonightR_instruction121) -PUBLIC FN_PREFIX(CryptonightR_instruction122) -PUBLIC FN_PREFIX(CryptonightR_instruction123) -PUBLIC FN_PREFIX(CryptonightR_instruction124) -PUBLIC FN_PREFIX(CryptonightR_instruction125) -PUBLIC FN_PREFIX(CryptonightR_instruction126) -PUBLIC FN_PREFIX(CryptonightR_instruction127) -PUBLIC FN_PREFIX(CryptonightR_instruction128) -PUBLIC FN_PREFIX(CryptonightR_instruction129) -PUBLIC FN_PREFIX(CryptonightR_instruction130) -PUBLIC FN_PREFIX(CryptonightR_instruction131) -PUBLIC FN_PREFIX(CryptonightR_instruction132) -PUBLIC FN_PREFIX(CryptonightR_instruction133) -PUBLIC FN_PREFIX(CryptonightR_instruction134) -PUBLIC FN_PREFIX(CryptonightR_instruction135) -PUBLIC FN_PREFIX(CryptonightR_instruction136) -PUBLIC FN_PREFIX(CryptonightR_instruction137) -PUBLIC FN_PREFIX(CryptonightR_instruction138) -PUBLIC FN_PREFIX(CryptonightR_instruction139) -PUBLIC FN_PREFIX(CryptonightR_instruction140) -PUBLIC FN_PREFIX(CryptonightR_instruction141) -PUBLIC FN_PREFIX(CryptonightR_instruction142) -PUBLIC FN_PREFIX(CryptonightR_instruction143) -PUBLIC FN_PREFIX(CryptonightR_instruction144) -PUBLIC FN_PREFIX(CryptonightR_instruction145) -PUBLIC FN_PREFIX(CryptonightR_instruction146) -PUBLIC FN_PREFIX(CryptonightR_instruction147) -PUBLIC FN_PREFIX(CryptonightR_instruction148) -PUBLIC FN_PREFIX(CryptonightR_instruction149) -PUBLIC FN_PREFIX(CryptonightR_instruction150) -PUBLIC FN_PREFIX(CryptonightR_instruction151) -PUBLIC FN_PREFIX(CryptonightR_instruction152) -PUBLIC FN_PREFIX(CryptonightR_instruction153) -PUBLIC FN_PREFIX(CryptonightR_instruction154) -PUBLIC FN_PREFIX(CryptonightR_instruction155) -PUBLIC FN_PREFIX(CryptonightR_instruction156) -PUBLIC FN_PREFIX(CryptonightR_instruction157) -PUBLIC FN_PREFIX(CryptonightR_instruction158) -PUBLIC FN_PREFIX(CryptonightR_instruction159) -PUBLIC FN_PREFIX(CryptonightR_instruction160) -PUBLIC FN_PREFIX(CryptonightR_instruction161) -PUBLIC FN_PREFIX(CryptonightR_instruction162) -PUBLIC FN_PREFIX(CryptonightR_instruction163) -PUBLIC FN_PREFIX(CryptonightR_instruction164) -PUBLIC FN_PREFIX(CryptonightR_instruction165) -PUBLIC FN_PREFIX(CryptonightR_instruction166) -PUBLIC FN_PREFIX(CryptonightR_instruction167) -PUBLIC FN_PREFIX(CryptonightR_instruction168) -PUBLIC FN_PREFIX(CryptonightR_instruction169) -PUBLIC FN_PREFIX(CryptonightR_instruction170) -PUBLIC FN_PREFIX(CryptonightR_instruction171) -PUBLIC FN_PREFIX(CryptonightR_instruction172) -PUBLIC FN_PREFIX(CryptonightR_instruction173) -PUBLIC FN_PREFIX(CryptonightR_instruction174) -PUBLIC FN_PREFIX(CryptonightR_instruction175) -PUBLIC FN_PREFIX(CryptonightR_instruction176) -PUBLIC FN_PREFIX(CryptonightR_instruction177) -PUBLIC FN_PREFIX(CryptonightR_instruction178) -PUBLIC FN_PREFIX(CryptonightR_instruction179) -PUBLIC FN_PREFIX(CryptonightR_instruction180) -PUBLIC FN_PREFIX(CryptonightR_instruction181) -PUBLIC FN_PREFIX(CryptonightR_instruction182) -PUBLIC FN_PREFIX(CryptonightR_instruction183) -PUBLIC FN_PREFIX(CryptonightR_instruction184) -PUBLIC FN_PREFIX(CryptonightR_instruction185) -PUBLIC FN_PREFIX(CryptonightR_instruction186) -PUBLIC FN_PREFIX(CryptonightR_instruction187) -PUBLIC FN_PREFIX(CryptonightR_instruction188) -PUBLIC FN_PREFIX(CryptonightR_instruction189) -PUBLIC FN_PREFIX(CryptonightR_instruction190) -PUBLIC FN_PREFIX(CryptonightR_instruction191) -PUBLIC FN_PREFIX(CryptonightR_instruction192) -PUBLIC FN_PREFIX(CryptonightR_instruction193) -PUBLIC FN_PREFIX(CryptonightR_instruction194) -PUBLIC FN_PREFIX(CryptonightR_instruction195) -PUBLIC FN_PREFIX(CryptonightR_instruction196) -PUBLIC FN_PREFIX(CryptonightR_instruction197) -PUBLIC FN_PREFIX(CryptonightR_instruction198) -PUBLIC FN_PREFIX(CryptonightR_instruction199) -PUBLIC FN_PREFIX(CryptonightR_instruction200) -PUBLIC FN_PREFIX(CryptonightR_instruction201) -PUBLIC FN_PREFIX(CryptonightR_instruction202) -PUBLIC FN_PREFIX(CryptonightR_instruction203) -PUBLIC FN_PREFIX(CryptonightR_instruction204) -PUBLIC FN_PREFIX(CryptonightR_instruction205) -PUBLIC FN_PREFIX(CryptonightR_instruction206) -PUBLIC FN_PREFIX(CryptonightR_instruction207) -PUBLIC FN_PREFIX(CryptonightR_instruction208) -PUBLIC FN_PREFIX(CryptonightR_instruction209) -PUBLIC FN_PREFIX(CryptonightR_instruction210) -PUBLIC FN_PREFIX(CryptonightR_instruction211) -PUBLIC FN_PREFIX(CryptonightR_instruction212) -PUBLIC FN_PREFIX(CryptonightR_instruction213) -PUBLIC FN_PREFIX(CryptonightR_instruction214) -PUBLIC FN_PREFIX(CryptonightR_instruction215) -PUBLIC FN_PREFIX(CryptonightR_instruction216) -PUBLIC FN_PREFIX(CryptonightR_instruction217) -PUBLIC FN_PREFIX(CryptonightR_instruction218) -PUBLIC FN_PREFIX(CryptonightR_instruction219) -PUBLIC FN_PREFIX(CryptonightR_instruction220) -PUBLIC FN_PREFIX(CryptonightR_instruction221) -PUBLIC FN_PREFIX(CryptonightR_instruction222) -PUBLIC FN_PREFIX(CryptonightR_instruction223) -PUBLIC FN_PREFIX(CryptonightR_instruction224) -PUBLIC FN_PREFIX(CryptonightR_instruction225) -PUBLIC FN_PREFIX(CryptonightR_instruction226) -PUBLIC FN_PREFIX(CryptonightR_instruction227) -PUBLIC FN_PREFIX(CryptonightR_instruction228) -PUBLIC FN_PREFIX(CryptonightR_instruction229) -PUBLIC FN_PREFIX(CryptonightR_instruction230) -PUBLIC FN_PREFIX(CryptonightR_instruction231) -PUBLIC FN_PREFIX(CryptonightR_instruction232) -PUBLIC FN_PREFIX(CryptonightR_instruction233) -PUBLIC FN_PREFIX(CryptonightR_instruction234) -PUBLIC FN_PREFIX(CryptonightR_instruction235) -PUBLIC FN_PREFIX(CryptonightR_instruction236) -PUBLIC FN_PREFIX(CryptonightR_instruction237) -PUBLIC FN_PREFIX(CryptonightR_instruction238) -PUBLIC FN_PREFIX(CryptonightR_instruction239) -PUBLIC FN_PREFIX(CryptonightR_instruction240) -PUBLIC FN_PREFIX(CryptonightR_instruction241) -PUBLIC FN_PREFIX(CryptonightR_instruction242) -PUBLIC FN_PREFIX(CryptonightR_instruction243) -PUBLIC FN_PREFIX(CryptonightR_instruction244) -PUBLIC FN_PREFIX(CryptonightR_instruction245) -PUBLIC FN_PREFIX(CryptonightR_instruction246) -PUBLIC FN_PREFIX(CryptonightR_instruction247) -PUBLIC FN_PREFIX(CryptonightR_instruction248) -PUBLIC FN_PREFIX(CryptonightR_instruction249) -PUBLIC FN_PREFIX(CryptonightR_instruction250) -PUBLIC FN_PREFIX(CryptonightR_instruction251) -PUBLIC FN_PREFIX(CryptonightR_instruction252) -PUBLIC FN_PREFIX(CryptonightR_instruction253) -PUBLIC FN_PREFIX(CryptonightR_instruction254) -PUBLIC FN_PREFIX(CryptonightR_instruction255) -PUBLIC FN_PREFIX(CryptonightR_instruction256) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov0) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov1) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov2) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov3) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov4) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov5) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov6) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov7) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov8) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov9) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov10) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov11) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov12) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov13) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov14) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov15) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov16) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov17) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov18) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov19) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov20) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov21) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov22) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov23) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov24) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov25) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov26) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov27) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov28) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov29) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov30) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov31) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov32) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov33) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov34) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov35) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov36) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov37) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov38) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov39) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov40) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov41) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov42) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov43) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov44) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov45) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov46) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov47) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov48) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov49) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov50) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov51) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov52) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov53) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov54) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov55) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov56) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov57) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov58) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov59) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov60) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov61) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov62) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov63) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov64) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov65) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov66) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov67) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov68) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov69) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov70) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov71) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov72) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov73) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov74) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov75) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov76) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov77) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov78) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov79) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov80) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov81) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov82) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov83) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov84) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov85) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov86) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov87) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov88) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov89) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov90) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov91) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov92) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov93) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov94) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov95) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov96) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov97) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov98) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov99) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov100) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov101) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov102) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov103) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov104) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov105) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov106) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov107) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov108) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov109) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov110) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov111) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov112) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov113) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov114) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov115) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov116) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov117) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov118) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov119) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov120) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov121) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov122) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov123) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov124) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov125) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov126) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov127) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov128) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov129) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov130) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov131) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov132) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov133) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov134) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov135) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov136) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov137) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov138) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov139) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov140) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov141) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov142) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov143) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov144) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov145) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov146) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov147) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov148) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov149) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov150) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov151) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov152) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov153) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov154) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov155) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov156) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov157) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov158) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov159) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov160) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov161) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov162) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov163) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov164) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov165) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov166) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov167) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov168) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov169) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov170) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov171) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov172) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov173) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov174) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov175) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov176) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov177) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov178) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov179) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov180) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov181) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov182) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov183) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov184) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov185) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov186) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov187) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov188) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov189) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov190) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov191) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov192) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov193) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov194) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov195) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov196) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov197) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov198) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov199) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov200) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov201) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov202) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov203) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov204) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov205) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov206) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov207) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov208) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov209) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov210) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov211) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov212) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov213) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov214) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov215) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov216) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov217) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov218) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov219) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov220) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov221) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov222) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov223) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov224) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov225) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov226) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov227) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov228) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov229) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov230) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov231) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov232) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov233) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov234) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov235) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov236) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov237) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov238) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov239) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov240) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov241) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov242) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov243) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov244) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov245) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov246) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov247) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov248) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov249) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov250) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov251) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov252) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov253) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov254) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov255) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov256) - -#include "CryptonightWOW_template.inc" -#include "CryptonightR_template.inc" -#include "CryptonightWOW_soft_aes_template.inc" -#include "CryptonightR_soft_aes_template.inc" - -FN_PREFIX(CryptonightR_instruction0): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction1): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction2): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction3): - add rbx, r9 - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction4): - sub rbx, r9 -FN_PREFIX(CryptonightR_instruction5): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction6): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction7): - xor rbx, r9 -FN_PREFIX(CryptonightR_instruction8): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction9): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction10): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction11): - add rsi, rbx - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction12): - sub rsi, rbx -FN_PREFIX(CryptonightR_instruction13): - ror esi, cl -FN_PREFIX(CryptonightR_instruction14): - rol esi, cl -FN_PREFIX(CryptonightR_instruction15): - xor rsi, rbx -FN_PREFIX(CryptonightR_instruction16): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction17): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction18): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction19): - add rdi, rbx - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction20): - sub rdi, rbx -FN_PREFIX(CryptonightR_instruction21): - ror edi, cl -FN_PREFIX(CryptonightR_instruction22): - rol edi, cl -FN_PREFIX(CryptonightR_instruction23): - xor rdi, rbx -FN_PREFIX(CryptonightR_instruction24): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction25): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction26): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction27): - add rbp, rbx - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction28): - sub rbp, rbx -FN_PREFIX(CryptonightR_instruction29): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction30): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction31): - xor rbp, rbx -FN_PREFIX(CryptonightR_instruction32): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction33): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction34): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction35): - add rbx, rsi - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction36): - sub rbx, rsi -FN_PREFIX(CryptonightR_instruction37): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction38): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction39): - xor rbx, rsi -FN_PREFIX(CryptonightR_instruction40): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction41): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction42): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction43): - add rsi, r9 - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction44): - sub rsi, r9 -FN_PREFIX(CryptonightR_instruction45): - ror esi, cl -FN_PREFIX(CryptonightR_instruction46): - rol esi, cl -FN_PREFIX(CryptonightR_instruction47): - xor rsi, r9 -FN_PREFIX(CryptonightR_instruction48): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction49): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction50): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction51): - add rdi, rsi - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction52): - sub rdi, rsi -FN_PREFIX(CryptonightR_instruction53): - ror edi, cl -FN_PREFIX(CryptonightR_instruction54): - rol edi, cl -FN_PREFIX(CryptonightR_instruction55): - xor rdi, rsi -FN_PREFIX(CryptonightR_instruction56): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction57): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction58): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction59): - add rbp, rsi - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction60): - sub rbp, rsi -FN_PREFIX(CryptonightR_instruction61): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction62): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction63): - xor rbp, rsi -FN_PREFIX(CryptonightR_instruction64): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction65): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction66): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction67): - add rbx, rdi - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction68): - sub rbx, rdi -FN_PREFIX(CryptonightR_instruction69): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction70): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction71): - xor rbx, rdi -FN_PREFIX(CryptonightR_instruction72): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction73): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction74): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction75): - add rsi, rdi - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction76): - sub rsi, rdi -FN_PREFIX(CryptonightR_instruction77): - ror esi, cl -FN_PREFIX(CryptonightR_instruction78): - rol esi, cl -FN_PREFIX(CryptonightR_instruction79): - xor rsi, rdi -FN_PREFIX(CryptonightR_instruction80): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction81): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction82): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction83): - add rdi, r9 - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction84): - sub rdi, r9 -FN_PREFIX(CryptonightR_instruction85): - ror edi, cl -FN_PREFIX(CryptonightR_instruction86): - rol edi, cl -FN_PREFIX(CryptonightR_instruction87): - xor rdi, r9 -FN_PREFIX(CryptonightR_instruction88): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction89): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction90): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction91): - add rbp, rdi - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction92): - sub rbp, rdi -FN_PREFIX(CryptonightR_instruction93): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction94): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction95): - xor rbp, rdi -FN_PREFIX(CryptonightR_instruction96): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction97): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction98): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction99): - add rbx, rbp - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction100): - sub rbx, rbp -FN_PREFIX(CryptonightR_instruction101): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction102): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction103): - xor rbx, rbp -FN_PREFIX(CryptonightR_instruction104): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction105): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction106): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction107): - add rsi, rbp - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction108): - sub rsi, rbp -FN_PREFIX(CryptonightR_instruction109): - ror esi, cl -FN_PREFIX(CryptonightR_instruction110): - rol esi, cl -FN_PREFIX(CryptonightR_instruction111): - xor rsi, rbp -FN_PREFIX(CryptonightR_instruction112): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction113): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction114): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction115): - add rdi, rbp - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction116): - sub rdi, rbp -FN_PREFIX(CryptonightR_instruction117): - ror edi, cl -FN_PREFIX(CryptonightR_instruction118): - rol edi, cl -FN_PREFIX(CryptonightR_instruction119): - xor rdi, rbp -FN_PREFIX(CryptonightR_instruction120): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction121): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction122): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction123): - add rbp, r9 - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction124): - sub rbp, r9 -FN_PREFIX(CryptonightR_instruction125): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction126): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction127): - xor rbp, r9 -FN_PREFIX(CryptonightR_instruction128): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction129): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction130): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction131): - add rbx, rsp - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction132): - sub rbx, rsp -FN_PREFIX(CryptonightR_instruction133): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction134): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction135): - xor rbx, rsp -FN_PREFIX(CryptonightR_instruction136): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction137): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction138): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction139): - add rsi, rsp - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction140): - sub rsi, rsp -FN_PREFIX(CryptonightR_instruction141): - ror esi, cl -FN_PREFIX(CryptonightR_instruction142): - rol esi, cl -FN_PREFIX(CryptonightR_instruction143): - xor rsi, rsp -FN_PREFIX(CryptonightR_instruction144): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction145): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction146): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction147): - add rdi, rsp - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction148): - sub rdi, rsp -FN_PREFIX(CryptonightR_instruction149): - ror edi, cl -FN_PREFIX(CryptonightR_instruction150): - rol edi, cl -FN_PREFIX(CryptonightR_instruction151): - xor rdi, rsp -FN_PREFIX(CryptonightR_instruction152): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction153): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction154): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction155): - add rbp, rsp - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction156): - sub rbp, rsp -FN_PREFIX(CryptonightR_instruction157): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction158): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction159): - xor rbp, rsp -FN_PREFIX(CryptonightR_instruction160): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction161): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction162): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction163): - add rbx, r15 - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction164): - sub rbx, r15 -FN_PREFIX(CryptonightR_instruction165): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction166): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction167): - xor rbx, r15 -FN_PREFIX(CryptonightR_instruction168): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction169): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction170): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction171): - add rsi, r15 - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction172): - sub rsi, r15 -FN_PREFIX(CryptonightR_instruction173): - ror esi, cl -FN_PREFIX(CryptonightR_instruction174): - rol esi, cl -FN_PREFIX(CryptonightR_instruction175): - xor rsi, r15 -FN_PREFIX(CryptonightR_instruction176): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction177): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction178): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction179): - add rdi, r15 - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction180): - sub rdi, r15 -FN_PREFIX(CryptonightR_instruction181): - ror edi, cl -FN_PREFIX(CryptonightR_instruction182): - rol edi, cl -FN_PREFIX(CryptonightR_instruction183): - xor rdi, r15 -FN_PREFIX(CryptonightR_instruction184): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction185): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction186): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction187): - add rbp, r15 - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction188): - sub rbp, r15 -FN_PREFIX(CryptonightR_instruction189): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction190): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction191): - xor rbp, r15 -FN_PREFIX(CryptonightR_instruction192): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction193): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction194): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction195): - add rbx, rax - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction196): - sub rbx, rax -FN_PREFIX(CryptonightR_instruction197): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction198): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction199): - xor rbx, rax -FN_PREFIX(CryptonightR_instruction200): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction201): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction202): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction203): - add rsi, rax - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction204): - sub rsi, rax -FN_PREFIX(CryptonightR_instruction205): - ror esi, cl -FN_PREFIX(CryptonightR_instruction206): - rol esi, cl -FN_PREFIX(CryptonightR_instruction207): - xor rsi, rax -FN_PREFIX(CryptonightR_instruction208): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction209): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction210): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction211): - add rdi, rax - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction212): - sub rdi, rax -FN_PREFIX(CryptonightR_instruction213): - ror edi, cl -FN_PREFIX(CryptonightR_instruction214): - rol edi, cl -FN_PREFIX(CryptonightR_instruction215): - xor rdi, rax -FN_PREFIX(CryptonightR_instruction216): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction217): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction218): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction219): - add rbp, rax - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction220): - sub rbp, rax -FN_PREFIX(CryptonightR_instruction221): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction222): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction223): - xor rbp, rax -FN_PREFIX(CryptonightR_instruction224): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction225): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction226): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction227): - add rbx, rdx - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction228): - sub rbx, rdx -FN_PREFIX(CryptonightR_instruction229): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction230): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction231): - xor rbx, rdx -FN_PREFIX(CryptonightR_instruction232): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction233): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction234): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction235): - add rsi, rdx - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction236): - sub rsi, rdx -FN_PREFIX(CryptonightR_instruction237): - ror esi, cl -FN_PREFIX(CryptonightR_instruction238): - rol esi, cl -FN_PREFIX(CryptonightR_instruction239): - xor rsi, rdx -FN_PREFIX(CryptonightR_instruction240): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction241): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction242): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction243): - add rdi, rdx - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction244): - sub rdi, rdx -FN_PREFIX(CryptonightR_instruction245): - ror edi, cl -FN_PREFIX(CryptonightR_instruction246): - rol edi, cl -FN_PREFIX(CryptonightR_instruction247): - xor rdi, rdx -FN_PREFIX(CryptonightR_instruction248): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction249): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction250): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction251): - add rbp, rdx - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction252): - sub rbp, rdx -FN_PREFIX(CryptonightR_instruction253): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction254): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction255): - xor rbp, rdx -FN_PREFIX(CryptonightR_instruction256): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction_mov0): - -FN_PREFIX(CryptonightR_instruction_mov1): - -FN_PREFIX(CryptonightR_instruction_mov2): - -FN_PREFIX(CryptonightR_instruction_mov3): - -FN_PREFIX(CryptonightR_instruction_mov4): - -FN_PREFIX(CryptonightR_instruction_mov5): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov6): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov7): - -FN_PREFIX(CryptonightR_instruction_mov8): - -FN_PREFIX(CryptonightR_instruction_mov9): - -FN_PREFIX(CryptonightR_instruction_mov10): - -FN_PREFIX(CryptonightR_instruction_mov11): - -FN_PREFIX(CryptonightR_instruction_mov12): - -FN_PREFIX(CryptonightR_instruction_mov13): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov14): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov15): - -FN_PREFIX(CryptonightR_instruction_mov16): - -FN_PREFIX(CryptonightR_instruction_mov17): - -FN_PREFIX(CryptonightR_instruction_mov18): - -FN_PREFIX(CryptonightR_instruction_mov19): - -FN_PREFIX(CryptonightR_instruction_mov20): - -FN_PREFIX(CryptonightR_instruction_mov21): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov22): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov23): - -FN_PREFIX(CryptonightR_instruction_mov24): - -FN_PREFIX(CryptonightR_instruction_mov25): - -FN_PREFIX(CryptonightR_instruction_mov26): - -FN_PREFIX(CryptonightR_instruction_mov27): - -FN_PREFIX(CryptonightR_instruction_mov28): - -FN_PREFIX(CryptonightR_instruction_mov29): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov30): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov31): - -FN_PREFIX(CryptonightR_instruction_mov32): - -FN_PREFIX(CryptonightR_instruction_mov33): - -FN_PREFIX(CryptonightR_instruction_mov34): - -FN_PREFIX(CryptonightR_instruction_mov35): - -FN_PREFIX(CryptonightR_instruction_mov36): - -FN_PREFIX(CryptonightR_instruction_mov37): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov38): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov39): - -FN_PREFIX(CryptonightR_instruction_mov40): - -FN_PREFIX(CryptonightR_instruction_mov41): - -FN_PREFIX(CryptonightR_instruction_mov42): - -FN_PREFIX(CryptonightR_instruction_mov43): - -FN_PREFIX(CryptonightR_instruction_mov44): - -FN_PREFIX(CryptonightR_instruction_mov45): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov46): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov47): - -FN_PREFIX(CryptonightR_instruction_mov48): - -FN_PREFIX(CryptonightR_instruction_mov49): - -FN_PREFIX(CryptonightR_instruction_mov50): - -FN_PREFIX(CryptonightR_instruction_mov51): - -FN_PREFIX(CryptonightR_instruction_mov52): - -FN_PREFIX(CryptonightR_instruction_mov53): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov54): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov55): - -FN_PREFIX(CryptonightR_instruction_mov56): - -FN_PREFIX(CryptonightR_instruction_mov57): - -FN_PREFIX(CryptonightR_instruction_mov58): - -FN_PREFIX(CryptonightR_instruction_mov59): - -FN_PREFIX(CryptonightR_instruction_mov60): - -FN_PREFIX(CryptonightR_instruction_mov61): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov62): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov63): - -FN_PREFIX(CryptonightR_instruction_mov64): - -FN_PREFIX(CryptonightR_instruction_mov65): - -FN_PREFIX(CryptonightR_instruction_mov66): - -FN_PREFIX(CryptonightR_instruction_mov67): - -FN_PREFIX(CryptonightR_instruction_mov68): - -FN_PREFIX(CryptonightR_instruction_mov69): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov70): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov71): - -FN_PREFIX(CryptonightR_instruction_mov72): - -FN_PREFIX(CryptonightR_instruction_mov73): - -FN_PREFIX(CryptonightR_instruction_mov74): - -FN_PREFIX(CryptonightR_instruction_mov75): - -FN_PREFIX(CryptonightR_instruction_mov76): - -FN_PREFIX(CryptonightR_instruction_mov77): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov78): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov79): - -FN_PREFIX(CryptonightR_instruction_mov80): - -FN_PREFIX(CryptonightR_instruction_mov81): - -FN_PREFIX(CryptonightR_instruction_mov82): - -FN_PREFIX(CryptonightR_instruction_mov83): - -FN_PREFIX(CryptonightR_instruction_mov84): - -FN_PREFIX(CryptonightR_instruction_mov85): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov86): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov87): - -FN_PREFIX(CryptonightR_instruction_mov88): - -FN_PREFIX(CryptonightR_instruction_mov89): - -FN_PREFIX(CryptonightR_instruction_mov90): - -FN_PREFIX(CryptonightR_instruction_mov91): - -FN_PREFIX(CryptonightR_instruction_mov92): - -FN_PREFIX(CryptonightR_instruction_mov93): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov94): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov95): - -FN_PREFIX(CryptonightR_instruction_mov96): - -FN_PREFIX(CryptonightR_instruction_mov97): - -FN_PREFIX(CryptonightR_instruction_mov98): - -FN_PREFIX(CryptonightR_instruction_mov99): - -FN_PREFIX(CryptonightR_instruction_mov100): - -FN_PREFIX(CryptonightR_instruction_mov101): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov102): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov103): - -FN_PREFIX(CryptonightR_instruction_mov104): - -FN_PREFIX(CryptonightR_instruction_mov105): - -FN_PREFIX(CryptonightR_instruction_mov106): - -FN_PREFIX(CryptonightR_instruction_mov107): - -FN_PREFIX(CryptonightR_instruction_mov108): - -FN_PREFIX(CryptonightR_instruction_mov109): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov110): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov111): - -FN_PREFIX(CryptonightR_instruction_mov112): - -FN_PREFIX(CryptonightR_instruction_mov113): - -FN_PREFIX(CryptonightR_instruction_mov114): - -FN_PREFIX(CryptonightR_instruction_mov115): - -FN_PREFIX(CryptonightR_instruction_mov116): - -FN_PREFIX(CryptonightR_instruction_mov117): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov118): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov119): - -FN_PREFIX(CryptonightR_instruction_mov120): - -FN_PREFIX(CryptonightR_instruction_mov121): - -FN_PREFIX(CryptonightR_instruction_mov122): - -FN_PREFIX(CryptonightR_instruction_mov123): - -FN_PREFIX(CryptonightR_instruction_mov124): - -FN_PREFIX(CryptonightR_instruction_mov125): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov126): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov127): - -FN_PREFIX(CryptonightR_instruction_mov128): - -FN_PREFIX(CryptonightR_instruction_mov129): - -FN_PREFIX(CryptonightR_instruction_mov130): - -FN_PREFIX(CryptonightR_instruction_mov131): - -FN_PREFIX(CryptonightR_instruction_mov132): - -FN_PREFIX(CryptonightR_instruction_mov133): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov134): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov135): - -FN_PREFIX(CryptonightR_instruction_mov136): - -FN_PREFIX(CryptonightR_instruction_mov137): - -FN_PREFIX(CryptonightR_instruction_mov138): - -FN_PREFIX(CryptonightR_instruction_mov139): - -FN_PREFIX(CryptonightR_instruction_mov140): - -FN_PREFIX(CryptonightR_instruction_mov141): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov142): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov143): - -FN_PREFIX(CryptonightR_instruction_mov144): - -FN_PREFIX(CryptonightR_instruction_mov145): - -FN_PREFIX(CryptonightR_instruction_mov146): - -FN_PREFIX(CryptonightR_instruction_mov147): - -FN_PREFIX(CryptonightR_instruction_mov148): - -FN_PREFIX(CryptonightR_instruction_mov149): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov150): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov151): - -FN_PREFIX(CryptonightR_instruction_mov152): - -FN_PREFIX(CryptonightR_instruction_mov153): - -FN_PREFIX(CryptonightR_instruction_mov154): - -FN_PREFIX(CryptonightR_instruction_mov155): - -FN_PREFIX(CryptonightR_instruction_mov156): - -FN_PREFIX(CryptonightR_instruction_mov157): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov158): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov159): - -FN_PREFIX(CryptonightR_instruction_mov160): - -FN_PREFIX(CryptonightR_instruction_mov161): - -FN_PREFIX(CryptonightR_instruction_mov162): - -FN_PREFIX(CryptonightR_instruction_mov163): - -FN_PREFIX(CryptonightR_instruction_mov164): - -FN_PREFIX(CryptonightR_instruction_mov165): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov166): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov167): - -FN_PREFIX(CryptonightR_instruction_mov168): - -FN_PREFIX(CryptonightR_instruction_mov169): - -FN_PREFIX(CryptonightR_instruction_mov170): - -FN_PREFIX(CryptonightR_instruction_mov171): - -FN_PREFIX(CryptonightR_instruction_mov172): - -FN_PREFIX(CryptonightR_instruction_mov173): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov174): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov175): - -FN_PREFIX(CryptonightR_instruction_mov176): - -FN_PREFIX(CryptonightR_instruction_mov177): - -FN_PREFIX(CryptonightR_instruction_mov178): - -FN_PREFIX(CryptonightR_instruction_mov179): - -FN_PREFIX(CryptonightR_instruction_mov180): - -FN_PREFIX(CryptonightR_instruction_mov181): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov182): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov183): - -FN_PREFIX(CryptonightR_instruction_mov184): - -FN_PREFIX(CryptonightR_instruction_mov185): - -FN_PREFIX(CryptonightR_instruction_mov186): - -FN_PREFIX(CryptonightR_instruction_mov187): - -FN_PREFIX(CryptonightR_instruction_mov188): - -FN_PREFIX(CryptonightR_instruction_mov189): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov190): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov191): - -FN_PREFIX(CryptonightR_instruction_mov192): - -FN_PREFIX(CryptonightR_instruction_mov193): - -FN_PREFIX(CryptonightR_instruction_mov194): - -FN_PREFIX(CryptonightR_instruction_mov195): - -FN_PREFIX(CryptonightR_instruction_mov196): - -FN_PREFIX(CryptonightR_instruction_mov197): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov198): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov199): - -FN_PREFIX(CryptonightR_instruction_mov200): - -FN_PREFIX(CryptonightR_instruction_mov201): - -FN_PREFIX(CryptonightR_instruction_mov202): - -FN_PREFIX(CryptonightR_instruction_mov203): - -FN_PREFIX(CryptonightR_instruction_mov204): - -FN_PREFIX(CryptonightR_instruction_mov205): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov206): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov207): - -FN_PREFIX(CryptonightR_instruction_mov208): - -FN_PREFIX(CryptonightR_instruction_mov209): - -FN_PREFIX(CryptonightR_instruction_mov210): - -FN_PREFIX(CryptonightR_instruction_mov211): - -FN_PREFIX(CryptonightR_instruction_mov212): - -FN_PREFIX(CryptonightR_instruction_mov213): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov214): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov215): - -FN_PREFIX(CryptonightR_instruction_mov216): - -FN_PREFIX(CryptonightR_instruction_mov217): - -FN_PREFIX(CryptonightR_instruction_mov218): - -FN_PREFIX(CryptonightR_instruction_mov219): - -FN_PREFIX(CryptonightR_instruction_mov220): - -FN_PREFIX(CryptonightR_instruction_mov221): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov222): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov223): - -FN_PREFIX(CryptonightR_instruction_mov224): - -FN_PREFIX(CryptonightR_instruction_mov225): - -FN_PREFIX(CryptonightR_instruction_mov226): - -FN_PREFIX(CryptonightR_instruction_mov227): - -FN_PREFIX(CryptonightR_instruction_mov228): - -FN_PREFIX(CryptonightR_instruction_mov229): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov230): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov231): - -FN_PREFIX(CryptonightR_instruction_mov232): - -FN_PREFIX(CryptonightR_instruction_mov233): - -FN_PREFIX(CryptonightR_instruction_mov234): - -FN_PREFIX(CryptonightR_instruction_mov235): - -FN_PREFIX(CryptonightR_instruction_mov236): - -FN_PREFIX(CryptonightR_instruction_mov237): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov238): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov239): - -FN_PREFIX(CryptonightR_instruction_mov240): - -FN_PREFIX(CryptonightR_instruction_mov241): - -FN_PREFIX(CryptonightR_instruction_mov242): - -FN_PREFIX(CryptonightR_instruction_mov243): - -FN_PREFIX(CryptonightR_instruction_mov244): - -FN_PREFIX(CryptonightR_instruction_mov245): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov246): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov247): - -FN_PREFIX(CryptonightR_instruction_mov248): - -FN_PREFIX(CryptonightR_instruction_mov249): - -FN_PREFIX(CryptonightR_instruction_mov250): - -FN_PREFIX(CryptonightR_instruction_mov251): - -FN_PREFIX(CryptonightR_instruction_mov252): - -FN_PREFIX(CryptonightR_instruction_mov253): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov254): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov255): - -FN_PREFIX(CryptonightR_instruction_mov256): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.h b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.h deleted file mode 100644 index d9159a8f26..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.h +++ /dev/null @@ -1,1087 +0,0 @@ -// Auto-generated file, do not edit - -extern "C" -{ - void CryptonightWOW_template_part1(); - void CryptonightWOW_template_mainloop(); - void CryptonightWOW_template_part2(); - void CryptonightWOW_template_part3(); - void CryptonightWOW_template_end(); - void CryptonightWOW_template_double_part1(); - void CryptonightWOW_template_double_mainloop(); - void CryptonightWOW_template_double_part2(); - void CryptonightWOW_template_double_part3(); - void CryptonightWOW_template_double_part4(); - void CryptonightWOW_template_double_end(); - - void CryptonightR_template_part1(); - void CryptonightR_template_mainloop(); - void CryptonightR_template_part2(); - void CryptonightR_template_part3(); - void CryptonightR_template_end(); - void CryptonightR_template_double_part1(); - void CryptonightR_template_double_mainloop(); - void CryptonightR_template_double_part2(); - void CryptonightR_template_double_part3(); - void CryptonightR_template_double_part4(); - void CryptonightR_template_double_end(); - - void CryptonightWOW_soft_aes_template_part1(); - void CryptonightWOW_soft_aes_template_mainloop(); - void CryptonightWOW_soft_aes_template_part2(); - void CryptonightWOW_soft_aes_template_part3(); - void CryptonightWOW_soft_aes_template_end(); - void CryptonightWOW_soft_aes_template_double_part1(); - void CryptonightWOW_soft_aes_template_double_mainloop(); - void CryptonightWOW_soft_aes_template_double_part2(); - void CryptonightWOW_soft_aes_template_double_part3(); - void CryptonightWOW_soft_aes_template_double_part4(); - void CryptonightWOW_soft_aes_template_double_end(); - - void CryptonightR_soft_aes_template_part1(); - void CryptonightR_soft_aes_template_mainloop(); - void CryptonightR_soft_aes_template_part2(); - void CryptonightR_soft_aes_template_part3(); - void CryptonightR_soft_aes_template_end(); - void CryptonightR_soft_aes_template_double_part1(); - void CryptonightR_soft_aes_template_double_mainloop(); - void CryptonightR_soft_aes_template_double_part2(); - void CryptonightR_soft_aes_template_double_part3(); - void CryptonightR_soft_aes_template_double_part4(); - void CryptonightR_soft_aes_template_double_end(); - - void CryptonightR_instruction0(); - void CryptonightR_instruction1(); - void CryptonightR_instruction2(); - void CryptonightR_instruction3(); - void CryptonightR_instruction4(); - void CryptonightR_instruction5(); - void CryptonightR_instruction6(); - void CryptonightR_instruction7(); - void CryptonightR_instruction8(); - void CryptonightR_instruction9(); - void CryptonightR_instruction10(); - void CryptonightR_instruction11(); - void CryptonightR_instruction12(); - void CryptonightR_instruction13(); - void CryptonightR_instruction14(); - void CryptonightR_instruction15(); - void CryptonightR_instruction16(); - void CryptonightR_instruction17(); - void CryptonightR_instruction18(); - void CryptonightR_instruction19(); - void CryptonightR_instruction20(); - void CryptonightR_instruction21(); - void CryptonightR_instruction22(); - void CryptonightR_instruction23(); - void CryptonightR_instruction24(); - void CryptonightR_instruction25(); - void CryptonightR_instruction26(); - void CryptonightR_instruction27(); - void CryptonightR_instruction28(); - void CryptonightR_instruction29(); - void CryptonightR_instruction30(); - void CryptonightR_instruction31(); - void CryptonightR_instruction32(); - void CryptonightR_instruction33(); - void CryptonightR_instruction34(); - void CryptonightR_instruction35(); - void CryptonightR_instruction36(); - void CryptonightR_instruction37(); - void CryptonightR_instruction38(); - void CryptonightR_instruction39(); - void CryptonightR_instruction40(); - void CryptonightR_instruction41(); - void CryptonightR_instruction42(); - void CryptonightR_instruction43(); - void CryptonightR_instruction44(); - void CryptonightR_instruction45(); - void CryptonightR_instruction46(); - void CryptonightR_instruction47(); - void CryptonightR_instruction48(); - void CryptonightR_instruction49(); - void CryptonightR_instruction50(); - void CryptonightR_instruction51(); - void CryptonightR_instruction52(); - void CryptonightR_instruction53(); - void CryptonightR_instruction54(); - void CryptonightR_instruction55(); - void CryptonightR_instruction56(); - void CryptonightR_instruction57(); - void CryptonightR_instruction58(); - void CryptonightR_instruction59(); - void CryptonightR_instruction60(); - void CryptonightR_instruction61(); - void CryptonightR_instruction62(); - void CryptonightR_instruction63(); - void CryptonightR_instruction64(); - void CryptonightR_instruction65(); - void CryptonightR_instruction66(); - void CryptonightR_instruction67(); - void CryptonightR_instruction68(); - void CryptonightR_instruction69(); - void CryptonightR_instruction70(); - void CryptonightR_instruction71(); - void CryptonightR_instruction72(); - void CryptonightR_instruction73(); - void CryptonightR_instruction74(); - void CryptonightR_instruction75(); - void CryptonightR_instruction76(); - void CryptonightR_instruction77(); - void CryptonightR_instruction78(); - void CryptonightR_instruction79(); - void CryptonightR_instruction80(); - void CryptonightR_instruction81(); - void CryptonightR_instruction82(); - void CryptonightR_instruction83(); - void CryptonightR_instruction84(); - void CryptonightR_instruction85(); - void CryptonightR_instruction86(); - void CryptonightR_instruction87(); - void CryptonightR_instruction88(); - void CryptonightR_instruction89(); - void CryptonightR_instruction90(); - void CryptonightR_instruction91(); - void CryptonightR_instruction92(); - void CryptonightR_instruction93(); - void CryptonightR_instruction94(); - void CryptonightR_instruction95(); - void CryptonightR_instruction96(); - void CryptonightR_instruction97(); - void CryptonightR_instruction98(); - void CryptonightR_instruction99(); - void CryptonightR_instruction100(); - void CryptonightR_instruction101(); - void CryptonightR_instruction102(); - void CryptonightR_instruction103(); - void CryptonightR_instruction104(); - void CryptonightR_instruction105(); - void CryptonightR_instruction106(); - void CryptonightR_instruction107(); - void CryptonightR_instruction108(); - void CryptonightR_instruction109(); - void CryptonightR_instruction110(); - void CryptonightR_instruction111(); - void CryptonightR_instruction112(); - void CryptonightR_instruction113(); - void CryptonightR_instruction114(); - void CryptonightR_instruction115(); - void CryptonightR_instruction116(); - void CryptonightR_instruction117(); - void CryptonightR_instruction118(); - void CryptonightR_instruction119(); - void CryptonightR_instruction120(); - void CryptonightR_instruction121(); - void CryptonightR_instruction122(); - void CryptonightR_instruction123(); - void CryptonightR_instruction124(); - void CryptonightR_instruction125(); - void CryptonightR_instruction126(); - void CryptonightR_instruction127(); - void CryptonightR_instruction128(); - void CryptonightR_instruction129(); - void CryptonightR_instruction130(); - void CryptonightR_instruction131(); - void CryptonightR_instruction132(); - void CryptonightR_instruction133(); - void CryptonightR_instruction134(); - void CryptonightR_instruction135(); - void CryptonightR_instruction136(); - void CryptonightR_instruction137(); - void CryptonightR_instruction138(); - void CryptonightR_instruction139(); - void CryptonightR_instruction140(); - void CryptonightR_instruction141(); - void CryptonightR_instruction142(); - void CryptonightR_instruction143(); - void CryptonightR_instruction144(); - void CryptonightR_instruction145(); - void CryptonightR_instruction146(); - void CryptonightR_instruction147(); - void CryptonightR_instruction148(); - void CryptonightR_instruction149(); - void CryptonightR_instruction150(); - void CryptonightR_instruction151(); - void CryptonightR_instruction152(); - void CryptonightR_instruction153(); - void CryptonightR_instruction154(); - void CryptonightR_instruction155(); - void CryptonightR_instruction156(); - void CryptonightR_instruction157(); - void CryptonightR_instruction158(); - void CryptonightR_instruction159(); - void CryptonightR_instruction160(); - void CryptonightR_instruction161(); - void CryptonightR_instruction162(); - void CryptonightR_instruction163(); - void CryptonightR_instruction164(); - void CryptonightR_instruction165(); - void CryptonightR_instruction166(); - void CryptonightR_instruction167(); - void CryptonightR_instruction168(); - void CryptonightR_instruction169(); - void CryptonightR_instruction170(); - void CryptonightR_instruction171(); - void CryptonightR_instruction172(); - void CryptonightR_instruction173(); - void CryptonightR_instruction174(); - void CryptonightR_instruction175(); - void CryptonightR_instruction176(); - void CryptonightR_instruction177(); - void CryptonightR_instruction178(); - void CryptonightR_instruction179(); - void CryptonightR_instruction180(); - void CryptonightR_instruction181(); - void CryptonightR_instruction182(); - void CryptonightR_instruction183(); - void CryptonightR_instruction184(); - void CryptonightR_instruction185(); - void CryptonightR_instruction186(); - void CryptonightR_instruction187(); - void CryptonightR_instruction188(); - void CryptonightR_instruction189(); - void CryptonightR_instruction190(); - void CryptonightR_instruction191(); - void CryptonightR_instruction192(); - void CryptonightR_instruction193(); - void CryptonightR_instruction194(); - void CryptonightR_instruction195(); - void CryptonightR_instruction196(); - void CryptonightR_instruction197(); - void CryptonightR_instruction198(); - void CryptonightR_instruction199(); - void CryptonightR_instruction200(); - void CryptonightR_instruction201(); - void CryptonightR_instruction202(); - void CryptonightR_instruction203(); - void CryptonightR_instruction204(); - void CryptonightR_instruction205(); - void CryptonightR_instruction206(); - void CryptonightR_instruction207(); - void CryptonightR_instruction208(); - void CryptonightR_instruction209(); - void CryptonightR_instruction210(); - void CryptonightR_instruction211(); - void CryptonightR_instruction212(); - void CryptonightR_instruction213(); - void CryptonightR_instruction214(); - void CryptonightR_instruction215(); - void CryptonightR_instruction216(); - void CryptonightR_instruction217(); - void CryptonightR_instruction218(); - void CryptonightR_instruction219(); - void CryptonightR_instruction220(); - void CryptonightR_instruction221(); - void CryptonightR_instruction222(); - void CryptonightR_instruction223(); - void CryptonightR_instruction224(); - void CryptonightR_instruction225(); - void CryptonightR_instruction226(); - void CryptonightR_instruction227(); - void CryptonightR_instruction228(); - void CryptonightR_instruction229(); - void CryptonightR_instruction230(); - void CryptonightR_instruction231(); - void CryptonightR_instruction232(); - void CryptonightR_instruction233(); - void CryptonightR_instruction234(); - void CryptonightR_instruction235(); - void CryptonightR_instruction236(); - void CryptonightR_instruction237(); - void CryptonightR_instruction238(); - void CryptonightR_instruction239(); - void CryptonightR_instruction240(); - void CryptonightR_instruction241(); - void CryptonightR_instruction242(); - void CryptonightR_instruction243(); - void CryptonightR_instruction244(); - void CryptonightR_instruction245(); - void CryptonightR_instruction246(); - void CryptonightR_instruction247(); - void CryptonightR_instruction248(); - void CryptonightR_instruction249(); - void CryptonightR_instruction250(); - void CryptonightR_instruction251(); - void CryptonightR_instruction252(); - void CryptonightR_instruction253(); - void CryptonightR_instruction254(); - void CryptonightR_instruction255(); - void CryptonightR_instruction256(); - void CryptonightR_instruction_mov0(); - void CryptonightR_instruction_mov1(); - void CryptonightR_instruction_mov2(); - void CryptonightR_instruction_mov3(); - void CryptonightR_instruction_mov4(); - void CryptonightR_instruction_mov5(); - void CryptonightR_instruction_mov6(); - void CryptonightR_instruction_mov7(); - void CryptonightR_instruction_mov8(); - void CryptonightR_instruction_mov9(); - void CryptonightR_instruction_mov10(); - void CryptonightR_instruction_mov11(); - void CryptonightR_instruction_mov12(); - void CryptonightR_instruction_mov13(); - void CryptonightR_instruction_mov14(); - void CryptonightR_instruction_mov15(); - void CryptonightR_instruction_mov16(); - void CryptonightR_instruction_mov17(); - void CryptonightR_instruction_mov18(); - void CryptonightR_instruction_mov19(); - void CryptonightR_instruction_mov20(); - void CryptonightR_instruction_mov21(); - void CryptonightR_instruction_mov22(); - void CryptonightR_instruction_mov23(); - void CryptonightR_instruction_mov24(); - void CryptonightR_instruction_mov25(); - void CryptonightR_instruction_mov26(); - void CryptonightR_instruction_mov27(); - void CryptonightR_instruction_mov28(); - void CryptonightR_instruction_mov29(); - void CryptonightR_instruction_mov30(); - void CryptonightR_instruction_mov31(); - void CryptonightR_instruction_mov32(); - void CryptonightR_instruction_mov33(); - void CryptonightR_instruction_mov34(); - void CryptonightR_instruction_mov35(); - void CryptonightR_instruction_mov36(); - void CryptonightR_instruction_mov37(); - void CryptonightR_instruction_mov38(); - void CryptonightR_instruction_mov39(); - void CryptonightR_instruction_mov40(); - void CryptonightR_instruction_mov41(); - void CryptonightR_instruction_mov42(); - void CryptonightR_instruction_mov43(); - void CryptonightR_instruction_mov44(); - void CryptonightR_instruction_mov45(); - void CryptonightR_instruction_mov46(); - void CryptonightR_instruction_mov47(); - void CryptonightR_instruction_mov48(); - void CryptonightR_instruction_mov49(); - void CryptonightR_instruction_mov50(); - void CryptonightR_instruction_mov51(); - void CryptonightR_instruction_mov52(); - void CryptonightR_instruction_mov53(); - void CryptonightR_instruction_mov54(); - void CryptonightR_instruction_mov55(); - void CryptonightR_instruction_mov56(); - void CryptonightR_instruction_mov57(); - void CryptonightR_instruction_mov58(); - void CryptonightR_instruction_mov59(); - void CryptonightR_instruction_mov60(); - void CryptonightR_instruction_mov61(); - void CryptonightR_instruction_mov62(); - void CryptonightR_instruction_mov63(); - void CryptonightR_instruction_mov64(); - void CryptonightR_instruction_mov65(); - void CryptonightR_instruction_mov66(); - void CryptonightR_instruction_mov67(); - void CryptonightR_instruction_mov68(); - void CryptonightR_instruction_mov69(); - void CryptonightR_instruction_mov70(); - void CryptonightR_instruction_mov71(); - void CryptonightR_instruction_mov72(); - void CryptonightR_instruction_mov73(); - void CryptonightR_instruction_mov74(); - void CryptonightR_instruction_mov75(); - void CryptonightR_instruction_mov76(); - void CryptonightR_instruction_mov77(); - void CryptonightR_instruction_mov78(); - void CryptonightR_instruction_mov79(); - void CryptonightR_instruction_mov80(); - void CryptonightR_instruction_mov81(); - void CryptonightR_instruction_mov82(); - void CryptonightR_instruction_mov83(); - void CryptonightR_instruction_mov84(); - void CryptonightR_instruction_mov85(); - void CryptonightR_instruction_mov86(); - void CryptonightR_instruction_mov87(); - void CryptonightR_instruction_mov88(); - void CryptonightR_instruction_mov89(); - void CryptonightR_instruction_mov90(); - void CryptonightR_instruction_mov91(); - void CryptonightR_instruction_mov92(); - void CryptonightR_instruction_mov93(); - void CryptonightR_instruction_mov94(); - void CryptonightR_instruction_mov95(); - void CryptonightR_instruction_mov96(); - void CryptonightR_instruction_mov97(); - void CryptonightR_instruction_mov98(); - void CryptonightR_instruction_mov99(); - void CryptonightR_instruction_mov100(); - void CryptonightR_instruction_mov101(); - void CryptonightR_instruction_mov102(); - void CryptonightR_instruction_mov103(); - void CryptonightR_instruction_mov104(); - void CryptonightR_instruction_mov105(); - void CryptonightR_instruction_mov106(); - void CryptonightR_instruction_mov107(); - void CryptonightR_instruction_mov108(); - void CryptonightR_instruction_mov109(); - void CryptonightR_instruction_mov110(); - void CryptonightR_instruction_mov111(); - void CryptonightR_instruction_mov112(); - void CryptonightR_instruction_mov113(); - void CryptonightR_instruction_mov114(); - void CryptonightR_instruction_mov115(); - void CryptonightR_instruction_mov116(); - void CryptonightR_instruction_mov117(); - void CryptonightR_instruction_mov118(); - void CryptonightR_instruction_mov119(); - void CryptonightR_instruction_mov120(); - void CryptonightR_instruction_mov121(); - void CryptonightR_instruction_mov122(); - void CryptonightR_instruction_mov123(); - void CryptonightR_instruction_mov124(); - void CryptonightR_instruction_mov125(); - void CryptonightR_instruction_mov126(); - void CryptonightR_instruction_mov127(); - void CryptonightR_instruction_mov128(); - void CryptonightR_instruction_mov129(); - void CryptonightR_instruction_mov130(); - void CryptonightR_instruction_mov131(); - void CryptonightR_instruction_mov132(); - void CryptonightR_instruction_mov133(); - void CryptonightR_instruction_mov134(); - void CryptonightR_instruction_mov135(); - void CryptonightR_instruction_mov136(); - void CryptonightR_instruction_mov137(); - void CryptonightR_instruction_mov138(); - void CryptonightR_instruction_mov139(); - void CryptonightR_instruction_mov140(); - void CryptonightR_instruction_mov141(); - void CryptonightR_instruction_mov142(); - void CryptonightR_instruction_mov143(); - void CryptonightR_instruction_mov144(); - void CryptonightR_instruction_mov145(); - void CryptonightR_instruction_mov146(); - void CryptonightR_instruction_mov147(); - void CryptonightR_instruction_mov148(); - void CryptonightR_instruction_mov149(); - void CryptonightR_instruction_mov150(); - void CryptonightR_instruction_mov151(); - void CryptonightR_instruction_mov152(); - void CryptonightR_instruction_mov153(); - void CryptonightR_instruction_mov154(); - void CryptonightR_instruction_mov155(); - void CryptonightR_instruction_mov156(); - void CryptonightR_instruction_mov157(); - void CryptonightR_instruction_mov158(); - void CryptonightR_instruction_mov159(); - void CryptonightR_instruction_mov160(); - void CryptonightR_instruction_mov161(); - void CryptonightR_instruction_mov162(); - void CryptonightR_instruction_mov163(); - void CryptonightR_instruction_mov164(); - void CryptonightR_instruction_mov165(); - void CryptonightR_instruction_mov166(); - void CryptonightR_instruction_mov167(); - void CryptonightR_instruction_mov168(); - void CryptonightR_instruction_mov169(); - void CryptonightR_instruction_mov170(); - void CryptonightR_instruction_mov171(); - void CryptonightR_instruction_mov172(); - void CryptonightR_instruction_mov173(); - void CryptonightR_instruction_mov174(); - void CryptonightR_instruction_mov175(); - void CryptonightR_instruction_mov176(); - void CryptonightR_instruction_mov177(); - void CryptonightR_instruction_mov178(); - void CryptonightR_instruction_mov179(); - void CryptonightR_instruction_mov180(); - void CryptonightR_instruction_mov181(); - void CryptonightR_instruction_mov182(); - void CryptonightR_instruction_mov183(); - void CryptonightR_instruction_mov184(); - void CryptonightR_instruction_mov185(); - void CryptonightR_instruction_mov186(); - void CryptonightR_instruction_mov187(); - void CryptonightR_instruction_mov188(); - void CryptonightR_instruction_mov189(); - void CryptonightR_instruction_mov190(); - void CryptonightR_instruction_mov191(); - void CryptonightR_instruction_mov192(); - void CryptonightR_instruction_mov193(); - void CryptonightR_instruction_mov194(); - void CryptonightR_instruction_mov195(); - void CryptonightR_instruction_mov196(); - void CryptonightR_instruction_mov197(); - void CryptonightR_instruction_mov198(); - void CryptonightR_instruction_mov199(); - void CryptonightR_instruction_mov200(); - void CryptonightR_instruction_mov201(); - void CryptonightR_instruction_mov202(); - void CryptonightR_instruction_mov203(); - void CryptonightR_instruction_mov204(); - void CryptonightR_instruction_mov205(); - void CryptonightR_instruction_mov206(); - void CryptonightR_instruction_mov207(); - void CryptonightR_instruction_mov208(); - void CryptonightR_instruction_mov209(); - void CryptonightR_instruction_mov210(); - void CryptonightR_instruction_mov211(); - void CryptonightR_instruction_mov212(); - void CryptonightR_instruction_mov213(); - void CryptonightR_instruction_mov214(); - void CryptonightR_instruction_mov215(); - void CryptonightR_instruction_mov216(); - void CryptonightR_instruction_mov217(); - void CryptonightR_instruction_mov218(); - void CryptonightR_instruction_mov219(); - void CryptonightR_instruction_mov220(); - void CryptonightR_instruction_mov221(); - void CryptonightR_instruction_mov222(); - void CryptonightR_instruction_mov223(); - void CryptonightR_instruction_mov224(); - void CryptonightR_instruction_mov225(); - void CryptonightR_instruction_mov226(); - void CryptonightR_instruction_mov227(); - void CryptonightR_instruction_mov228(); - void CryptonightR_instruction_mov229(); - void CryptonightR_instruction_mov230(); - void CryptonightR_instruction_mov231(); - void CryptonightR_instruction_mov232(); - void CryptonightR_instruction_mov233(); - void CryptonightR_instruction_mov234(); - void CryptonightR_instruction_mov235(); - void CryptonightR_instruction_mov236(); - void CryptonightR_instruction_mov237(); - void CryptonightR_instruction_mov238(); - void CryptonightR_instruction_mov239(); - void CryptonightR_instruction_mov240(); - void CryptonightR_instruction_mov241(); - void CryptonightR_instruction_mov242(); - void CryptonightR_instruction_mov243(); - void CryptonightR_instruction_mov244(); - void CryptonightR_instruction_mov245(); - void CryptonightR_instruction_mov246(); - void CryptonightR_instruction_mov247(); - void CryptonightR_instruction_mov248(); - void CryptonightR_instruction_mov249(); - void CryptonightR_instruction_mov250(); - void CryptonightR_instruction_mov251(); - void CryptonightR_instruction_mov252(); - void CryptonightR_instruction_mov253(); - void CryptonightR_instruction_mov254(); - void CryptonightR_instruction_mov255(); - void CryptonightR_instruction_mov256(); -} - -const void_func instructions[257] = { - CryptonightR_instruction0, - CryptonightR_instruction1, - CryptonightR_instruction2, - CryptonightR_instruction3, - CryptonightR_instruction4, - CryptonightR_instruction5, - CryptonightR_instruction6, - CryptonightR_instruction7, - CryptonightR_instruction8, - CryptonightR_instruction9, - CryptonightR_instruction10, - CryptonightR_instruction11, - CryptonightR_instruction12, - CryptonightR_instruction13, - CryptonightR_instruction14, - CryptonightR_instruction15, - CryptonightR_instruction16, - CryptonightR_instruction17, - CryptonightR_instruction18, - CryptonightR_instruction19, - CryptonightR_instruction20, - CryptonightR_instruction21, - CryptonightR_instruction22, - CryptonightR_instruction23, - CryptonightR_instruction24, - CryptonightR_instruction25, - CryptonightR_instruction26, - CryptonightR_instruction27, - CryptonightR_instruction28, - CryptonightR_instruction29, - CryptonightR_instruction30, - CryptonightR_instruction31, - CryptonightR_instruction32, - CryptonightR_instruction33, - CryptonightR_instruction34, - CryptonightR_instruction35, - CryptonightR_instruction36, - CryptonightR_instruction37, - CryptonightR_instruction38, - CryptonightR_instruction39, - CryptonightR_instruction40, - CryptonightR_instruction41, - CryptonightR_instruction42, - CryptonightR_instruction43, - CryptonightR_instruction44, - CryptonightR_instruction45, - CryptonightR_instruction46, - CryptonightR_instruction47, - CryptonightR_instruction48, - CryptonightR_instruction49, - CryptonightR_instruction50, - CryptonightR_instruction51, - CryptonightR_instruction52, - CryptonightR_instruction53, - CryptonightR_instruction54, - CryptonightR_instruction55, - CryptonightR_instruction56, - CryptonightR_instruction57, - CryptonightR_instruction58, - CryptonightR_instruction59, - CryptonightR_instruction60, - CryptonightR_instruction61, - CryptonightR_instruction62, - CryptonightR_instruction63, - CryptonightR_instruction64, - CryptonightR_instruction65, - CryptonightR_instruction66, - CryptonightR_instruction67, - CryptonightR_instruction68, - CryptonightR_instruction69, - CryptonightR_instruction70, - CryptonightR_instruction71, - CryptonightR_instruction72, - CryptonightR_instruction73, - CryptonightR_instruction74, - CryptonightR_instruction75, - CryptonightR_instruction76, - CryptonightR_instruction77, - CryptonightR_instruction78, - CryptonightR_instruction79, - CryptonightR_instruction80, - CryptonightR_instruction81, - CryptonightR_instruction82, - CryptonightR_instruction83, - CryptonightR_instruction84, - CryptonightR_instruction85, - CryptonightR_instruction86, - CryptonightR_instruction87, - CryptonightR_instruction88, - CryptonightR_instruction89, - CryptonightR_instruction90, - CryptonightR_instruction91, - CryptonightR_instruction92, - CryptonightR_instruction93, - CryptonightR_instruction94, - CryptonightR_instruction95, - CryptonightR_instruction96, - CryptonightR_instruction97, - CryptonightR_instruction98, - CryptonightR_instruction99, - CryptonightR_instruction100, - CryptonightR_instruction101, - CryptonightR_instruction102, - CryptonightR_instruction103, - CryptonightR_instruction104, - CryptonightR_instruction105, - CryptonightR_instruction106, - CryptonightR_instruction107, - CryptonightR_instruction108, - CryptonightR_instruction109, - CryptonightR_instruction110, - CryptonightR_instruction111, - CryptonightR_instruction112, - CryptonightR_instruction113, - CryptonightR_instruction114, - CryptonightR_instruction115, - CryptonightR_instruction116, - CryptonightR_instruction117, - CryptonightR_instruction118, - CryptonightR_instruction119, - CryptonightR_instruction120, - CryptonightR_instruction121, - CryptonightR_instruction122, - CryptonightR_instruction123, - CryptonightR_instruction124, - CryptonightR_instruction125, - CryptonightR_instruction126, - CryptonightR_instruction127, - CryptonightR_instruction128, - CryptonightR_instruction129, - CryptonightR_instruction130, - CryptonightR_instruction131, - CryptonightR_instruction132, - CryptonightR_instruction133, - CryptonightR_instruction134, - CryptonightR_instruction135, - CryptonightR_instruction136, - CryptonightR_instruction137, - CryptonightR_instruction138, - CryptonightR_instruction139, - CryptonightR_instruction140, - CryptonightR_instruction141, - CryptonightR_instruction142, - CryptonightR_instruction143, - CryptonightR_instruction144, - CryptonightR_instruction145, - CryptonightR_instruction146, - CryptonightR_instruction147, - CryptonightR_instruction148, - CryptonightR_instruction149, - CryptonightR_instruction150, - CryptonightR_instruction151, - CryptonightR_instruction152, - CryptonightR_instruction153, - CryptonightR_instruction154, - CryptonightR_instruction155, - CryptonightR_instruction156, - CryptonightR_instruction157, - CryptonightR_instruction158, - CryptonightR_instruction159, - CryptonightR_instruction160, - CryptonightR_instruction161, - CryptonightR_instruction162, - CryptonightR_instruction163, - CryptonightR_instruction164, - CryptonightR_instruction165, - CryptonightR_instruction166, - CryptonightR_instruction167, - CryptonightR_instruction168, - CryptonightR_instruction169, - CryptonightR_instruction170, - CryptonightR_instruction171, - CryptonightR_instruction172, - CryptonightR_instruction173, - CryptonightR_instruction174, - CryptonightR_instruction175, - CryptonightR_instruction176, - CryptonightR_instruction177, - CryptonightR_instruction178, - CryptonightR_instruction179, - CryptonightR_instruction180, - CryptonightR_instruction181, - CryptonightR_instruction182, - CryptonightR_instruction183, - CryptonightR_instruction184, - CryptonightR_instruction185, - CryptonightR_instruction186, - CryptonightR_instruction187, - CryptonightR_instruction188, - CryptonightR_instruction189, - CryptonightR_instruction190, - CryptonightR_instruction191, - CryptonightR_instruction192, - CryptonightR_instruction193, - CryptonightR_instruction194, - CryptonightR_instruction195, - CryptonightR_instruction196, - CryptonightR_instruction197, - CryptonightR_instruction198, - CryptonightR_instruction199, - CryptonightR_instruction200, - CryptonightR_instruction201, - CryptonightR_instruction202, - CryptonightR_instruction203, - CryptonightR_instruction204, - CryptonightR_instruction205, - CryptonightR_instruction206, - CryptonightR_instruction207, - CryptonightR_instruction208, - CryptonightR_instruction209, - CryptonightR_instruction210, - CryptonightR_instruction211, - CryptonightR_instruction212, - CryptonightR_instruction213, - CryptonightR_instruction214, - CryptonightR_instruction215, - CryptonightR_instruction216, - CryptonightR_instruction217, - CryptonightR_instruction218, - CryptonightR_instruction219, - CryptonightR_instruction220, - CryptonightR_instruction221, - CryptonightR_instruction222, - CryptonightR_instruction223, - CryptonightR_instruction224, - CryptonightR_instruction225, - CryptonightR_instruction226, - CryptonightR_instruction227, - CryptonightR_instruction228, - CryptonightR_instruction229, - CryptonightR_instruction230, - CryptonightR_instruction231, - CryptonightR_instruction232, - CryptonightR_instruction233, - CryptonightR_instruction234, - CryptonightR_instruction235, - CryptonightR_instruction236, - CryptonightR_instruction237, - CryptonightR_instruction238, - CryptonightR_instruction239, - CryptonightR_instruction240, - CryptonightR_instruction241, - CryptonightR_instruction242, - CryptonightR_instruction243, - CryptonightR_instruction244, - CryptonightR_instruction245, - CryptonightR_instruction246, - CryptonightR_instruction247, - CryptonightR_instruction248, - CryptonightR_instruction249, - CryptonightR_instruction250, - CryptonightR_instruction251, - CryptonightR_instruction252, - CryptonightR_instruction253, - CryptonightR_instruction254, - CryptonightR_instruction255, - CryptonightR_instruction256, -}; - -const void_func instructions_mov[257] = { - CryptonightR_instruction_mov0, - CryptonightR_instruction_mov1, - CryptonightR_instruction_mov2, - CryptonightR_instruction_mov3, - CryptonightR_instruction_mov4, - CryptonightR_instruction_mov5, - CryptonightR_instruction_mov6, - CryptonightR_instruction_mov7, - CryptonightR_instruction_mov8, - CryptonightR_instruction_mov9, - CryptonightR_instruction_mov10, - CryptonightR_instruction_mov11, - CryptonightR_instruction_mov12, - CryptonightR_instruction_mov13, - CryptonightR_instruction_mov14, - CryptonightR_instruction_mov15, - CryptonightR_instruction_mov16, - CryptonightR_instruction_mov17, - CryptonightR_instruction_mov18, - CryptonightR_instruction_mov19, - CryptonightR_instruction_mov20, - CryptonightR_instruction_mov21, - CryptonightR_instruction_mov22, - CryptonightR_instruction_mov23, - CryptonightR_instruction_mov24, - CryptonightR_instruction_mov25, - CryptonightR_instruction_mov26, - CryptonightR_instruction_mov27, - CryptonightR_instruction_mov28, - CryptonightR_instruction_mov29, - CryptonightR_instruction_mov30, - CryptonightR_instruction_mov31, - CryptonightR_instruction_mov32, - CryptonightR_instruction_mov33, - CryptonightR_instruction_mov34, - CryptonightR_instruction_mov35, - CryptonightR_instruction_mov36, - CryptonightR_instruction_mov37, - CryptonightR_instruction_mov38, - CryptonightR_instruction_mov39, - CryptonightR_instruction_mov40, - CryptonightR_instruction_mov41, - CryptonightR_instruction_mov42, - CryptonightR_instruction_mov43, - CryptonightR_instruction_mov44, - CryptonightR_instruction_mov45, - CryptonightR_instruction_mov46, - CryptonightR_instruction_mov47, - CryptonightR_instruction_mov48, - CryptonightR_instruction_mov49, - CryptonightR_instruction_mov50, - CryptonightR_instruction_mov51, - CryptonightR_instruction_mov52, - CryptonightR_instruction_mov53, - CryptonightR_instruction_mov54, - CryptonightR_instruction_mov55, - CryptonightR_instruction_mov56, - CryptonightR_instruction_mov57, - CryptonightR_instruction_mov58, - CryptonightR_instruction_mov59, - CryptonightR_instruction_mov60, - CryptonightR_instruction_mov61, - CryptonightR_instruction_mov62, - CryptonightR_instruction_mov63, - CryptonightR_instruction_mov64, - CryptonightR_instruction_mov65, - CryptonightR_instruction_mov66, - CryptonightR_instruction_mov67, - CryptonightR_instruction_mov68, - CryptonightR_instruction_mov69, - CryptonightR_instruction_mov70, - CryptonightR_instruction_mov71, - CryptonightR_instruction_mov72, - CryptonightR_instruction_mov73, - CryptonightR_instruction_mov74, - CryptonightR_instruction_mov75, - CryptonightR_instruction_mov76, - CryptonightR_instruction_mov77, - CryptonightR_instruction_mov78, - CryptonightR_instruction_mov79, - CryptonightR_instruction_mov80, - CryptonightR_instruction_mov81, - CryptonightR_instruction_mov82, - CryptonightR_instruction_mov83, - CryptonightR_instruction_mov84, - CryptonightR_instruction_mov85, - CryptonightR_instruction_mov86, - CryptonightR_instruction_mov87, - CryptonightR_instruction_mov88, - CryptonightR_instruction_mov89, - CryptonightR_instruction_mov90, - CryptonightR_instruction_mov91, - CryptonightR_instruction_mov92, - CryptonightR_instruction_mov93, - CryptonightR_instruction_mov94, - CryptonightR_instruction_mov95, - CryptonightR_instruction_mov96, - CryptonightR_instruction_mov97, - CryptonightR_instruction_mov98, - CryptonightR_instruction_mov99, - CryptonightR_instruction_mov100, - CryptonightR_instruction_mov101, - CryptonightR_instruction_mov102, - CryptonightR_instruction_mov103, - CryptonightR_instruction_mov104, - CryptonightR_instruction_mov105, - CryptonightR_instruction_mov106, - CryptonightR_instruction_mov107, - CryptonightR_instruction_mov108, - CryptonightR_instruction_mov109, - CryptonightR_instruction_mov110, - CryptonightR_instruction_mov111, - CryptonightR_instruction_mov112, - CryptonightR_instruction_mov113, - CryptonightR_instruction_mov114, - CryptonightR_instruction_mov115, - CryptonightR_instruction_mov116, - CryptonightR_instruction_mov117, - CryptonightR_instruction_mov118, - CryptonightR_instruction_mov119, - CryptonightR_instruction_mov120, - CryptonightR_instruction_mov121, - CryptonightR_instruction_mov122, - CryptonightR_instruction_mov123, - CryptonightR_instruction_mov124, - CryptonightR_instruction_mov125, - CryptonightR_instruction_mov126, - CryptonightR_instruction_mov127, - CryptonightR_instruction_mov128, - CryptonightR_instruction_mov129, - CryptonightR_instruction_mov130, - CryptonightR_instruction_mov131, - CryptonightR_instruction_mov132, - CryptonightR_instruction_mov133, - CryptonightR_instruction_mov134, - CryptonightR_instruction_mov135, - CryptonightR_instruction_mov136, - CryptonightR_instruction_mov137, - CryptonightR_instruction_mov138, - CryptonightR_instruction_mov139, - CryptonightR_instruction_mov140, - CryptonightR_instruction_mov141, - CryptonightR_instruction_mov142, - CryptonightR_instruction_mov143, - CryptonightR_instruction_mov144, - CryptonightR_instruction_mov145, - CryptonightR_instruction_mov146, - CryptonightR_instruction_mov147, - CryptonightR_instruction_mov148, - CryptonightR_instruction_mov149, - CryptonightR_instruction_mov150, - CryptonightR_instruction_mov151, - CryptonightR_instruction_mov152, - CryptonightR_instruction_mov153, - CryptonightR_instruction_mov154, - CryptonightR_instruction_mov155, - CryptonightR_instruction_mov156, - CryptonightR_instruction_mov157, - CryptonightR_instruction_mov158, - CryptonightR_instruction_mov159, - CryptonightR_instruction_mov160, - CryptonightR_instruction_mov161, - CryptonightR_instruction_mov162, - CryptonightR_instruction_mov163, - CryptonightR_instruction_mov164, - CryptonightR_instruction_mov165, - CryptonightR_instruction_mov166, - CryptonightR_instruction_mov167, - CryptonightR_instruction_mov168, - CryptonightR_instruction_mov169, - CryptonightR_instruction_mov170, - CryptonightR_instruction_mov171, - CryptonightR_instruction_mov172, - CryptonightR_instruction_mov173, - CryptonightR_instruction_mov174, - CryptonightR_instruction_mov175, - CryptonightR_instruction_mov176, - CryptonightR_instruction_mov177, - CryptonightR_instruction_mov178, - CryptonightR_instruction_mov179, - CryptonightR_instruction_mov180, - CryptonightR_instruction_mov181, - CryptonightR_instruction_mov182, - CryptonightR_instruction_mov183, - CryptonightR_instruction_mov184, - CryptonightR_instruction_mov185, - CryptonightR_instruction_mov186, - CryptonightR_instruction_mov187, - CryptonightR_instruction_mov188, - CryptonightR_instruction_mov189, - CryptonightR_instruction_mov190, - CryptonightR_instruction_mov191, - CryptonightR_instruction_mov192, - CryptonightR_instruction_mov193, - CryptonightR_instruction_mov194, - CryptonightR_instruction_mov195, - CryptonightR_instruction_mov196, - CryptonightR_instruction_mov197, - CryptonightR_instruction_mov198, - CryptonightR_instruction_mov199, - CryptonightR_instruction_mov200, - CryptonightR_instruction_mov201, - CryptonightR_instruction_mov202, - CryptonightR_instruction_mov203, - CryptonightR_instruction_mov204, - CryptonightR_instruction_mov205, - CryptonightR_instruction_mov206, - CryptonightR_instruction_mov207, - CryptonightR_instruction_mov208, - CryptonightR_instruction_mov209, - CryptonightR_instruction_mov210, - CryptonightR_instruction_mov211, - CryptonightR_instruction_mov212, - CryptonightR_instruction_mov213, - CryptonightR_instruction_mov214, - CryptonightR_instruction_mov215, - CryptonightR_instruction_mov216, - CryptonightR_instruction_mov217, - CryptonightR_instruction_mov218, - CryptonightR_instruction_mov219, - CryptonightR_instruction_mov220, - CryptonightR_instruction_mov221, - CryptonightR_instruction_mov222, - CryptonightR_instruction_mov223, - CryptonightR_instruction_mov224, - CryptonightR_instruction_mov225, - CryptonightR_instruction_mov226, - CryptonightR_instruction_mov227, - CryptonightR_instruction_mov228, - CryptonightR_instruction_mov229, - CryptonightR_instruction_mov230, - CryptonightR_instruction_mov231, - CryptonightR_instruction_mov232, - CryptonightR_instruction_mov233, - CryptonightR_instruction_mov234, - CryptonightR_instruction_mov235, - CryptonightR_instruction_mov236, - CryptonightR_instruction_mov237, - CryptonightR_instruction_mov238, - CryptonightR_instruction_mov239, - CryptonightR_instruction_mov240, - CryptonightR_instruction_mov241, - CryptonightR_instruction_mov242, - CryptonightR_instruction_mov243, - CryptonightR_instruction_mov244, - CryptonightR_instruction_mov245, - CryptonightR_instruction_mov246, - CryptonightR_instruction_mov247, - CryptonightR_instruction_mov248, - CryptonightR_instruction_mov249, - CryptonightR_instruction_mov250, - CryptonightR_instruction_mov251, - CryptonightR_instruction_mov252, - CryptonightR_instruction_mov253, - CryptonightR_instruction_mov254, - CryptonightR_instruction_mov255, - CryptonightR_instruction_mov256, -}; diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.inc deleted file mode 100644 index 8ecab7247f..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template.inc +++ /dev/null @@ -1,531 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightR_template_part1) -PUBLIC FN_PREFIX(CryptonightR_template_mainloop) -PUBLIC FN_PREFIX(CryptonightR_template_part2) -PUBLIC FN_PREFIX(CryptonightR_template_part3) -PUBLIC FN_PREFIX(CryptonightR_template_end) -PUBLIC FN_PREFIX(CryptonightR_template_double_part1) -PUBLIC FN_PREFIX(CryptonightR_template_double_mainloop) -PUBLIC FN_PREFIX(CryptonightR_template_double_part2) -PUBLIC FN_PREFIX(CryptonightR_template_double_part3) -PUBLIC FN_PREFIX(CryptonightR_template_double_part4) -PUBLIC FN_PREFIX(CryptonightR_template_double_end) - -ALIGN(64) -FN_PREFIX(CryptonightR_template_part1): - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movq xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movq xmm0, r12 - movq xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movq xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -FN_PREFIX(CryptonightR_template_mainloop): - movdqa xmm5, XMMWORD PTR [r9+r11] - movq xmm0, r15 - movq xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - - mov r13d, r9d - mov eax, r9d - xor r9d, 48 - xor r13d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movaps xmm3, xmm0 - movdqu xmm2, XMMWORD PTR [r13+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - pxor xmm0, xmm2 - pxor xmm5, xmm1 - pxor xmm5, xmm0 - - movq r12, xmm5 - movd r10d, xmm5 - and r10d, 2097136 - - paddq xmm3, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r13+r11], xmm3 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - -FN_PREFIX(CryptonightR_template_part2): - lea rcx, [r10+r11] - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor rsp, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov rax, r13 - mul r12 - add r15, rax - add rsp, rdx - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - movaps xmm3, xmm1 - movdqa xmm2, XMMWORD PTR [r9+r11] - movdqa xmm0, XMMWORD PTR [r10+r11] - pxor xmm1, xmm2 - pxor xmm5, xmm0 - pxor xmm5, xmm1 - paddq xmm3, xmm4 - paddq xmm2, xmm6 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqu XMMWORD PTR [r12+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm3 - - movdqa xmm7, xmm6 - mov QWORD PTR [rcx], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [rcx+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz FN_PREFIX(CryptonightR_template_mainloop) - -FN_PREFIX(CryptonightR_template_part3): - movq rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -FN_PREFIX(CryptonightR_template_end): - -ALIGN(64) -FN_PREFIX(CryptonightR_template_double_part1): - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movq xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movq xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movq xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movq xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movq xmm0, rcx - mov r11d, 524288 - movq xmm10, rax - punpcklqdq xmm10, xmm0 - - movq xmm14, QWORD PTR [rsp+128] - movq xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -FN_PREFIX(CryptonightR_template_double_mainloop): - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movq xmm0, r12 - mov ecx, ebx - movq xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movq xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm1 - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - movq rdx, xmm6 - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movq xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm1 - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movq rdi, xmm5 - movq rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movq xmm0, rsp - movq xmm1, rsi - movq xmm2, rdi - movq xmm11, rbp - movq xmm12, r15 - movq xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -FN_PREFIX(CryptonightR_template_double_part2): - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r14, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r12, rax - - movq rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movq rsi, xmm1 - movq rdi, xmm2 - movq rbp, xmm11 - movq r15, xmm12 - movq rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movdqu xmm1, XMMWORD PTR [rcx+rsi] - pxor xmm6, xmm1 - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - pxor xmm6, xmm2 - paddq xmm2, xmm3 - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - pxor xmm6, xmm0 - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movq rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movq xmm0, rsp - movq xmm1, rbx - movq xmm2, rsi - movq xmm11, rdi - movq xmm12, rbp - movq xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movq xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -FN_PREFIX(CryptonightR_template_double_part3): - - movq r15, xmm13 - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r13, rax - - movq rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movq rbx, xmm1 - movq rsi, xmm2 - movq rdi, xmm11 - movq rbp, xmm12 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - mov rdi, rcx - mov r8, rax - movdqu xmm1, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm1 - xor ebp, 48 - paddq xmm1, xmm8 - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm2 - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movq rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz FN_PREFIX(CryptonightR_template_double_mainloop) - -FN_PREFIX(CryptonightR_template_double_part4): - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -FN_PREFIX(CryptonightR_template_double_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template_win.inc deleted file mode 100644 index a170f2d2b5..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightR_template_win.inc +++ /dev/null @@ -1,531 +0,0 @@ -PUBLIC CryptonightR_template_part1 -PUBLIC CryptonightR_template_mainloop -PUBLIC CryptonightR_template_part2 -PUBLIC CryptonightR_template_part3 -PUBLIC CryptonightR_template_end -PUBLIC CryptonightR_template_double_part1 -PUBLIC CryptonightR_template_double_mainloop -PUBLIC CryptonightR_template_double_part2 -PUBLIC CryptonightR_template_double_part3 -PUBLIC CryptonightR_template_double_part4 -PUBLIC CryptonightR_template_double_end - -ALIGN(64) -CryptonightR_template_part1: - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movq xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movq xmm0, r12 - movq xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movq xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -CryptonightR_template_mainloop: - movdqa xmm5, XMMWORD PTR [r9+r11] - movq xmm0, r15 - movq xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - - mov r13d, r9d - mov eax, r9d - xor r9d, 48 - xor r13d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movaps xmm3, xmm0 - movdqu xmm2, XMMWORD PTR [r13+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - pxor xmm0, xmm2 - pxor xmm5, xmm1 - pxor xmm5, xmm0 - - movq r12, xmm5 - movd r10d, xmm5 - and r10d, 2097136 - - paddq xmm3, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r13+r11], xmm3 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - -CryptonightR_template_part2: - lea rcx, [r10+r11] - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor rsp, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov rax, r13 - mul r12 - add r15, rax - add rsp, rdx - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - movaps xmm3, xmm1 - movdqa xmm2, XMMWORD PTR [r9+r11] - movdqa xmm0, XMMWORD PTR [r10+r11] - pxor xmm1, xmm2 - pxor xmm5, xmm0 - pxor xmm5, xmm1 - paddq xmm3, xmm4 - paddq xmm2, xmm6 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqu XMMWORD PTR [r12+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm3 - - movdqa xmm7, xmm6 - mov QWORD PTR [rcx], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [rcx+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz CryptonightR_template_mainloop - -CryptonightR_template_part3: - movq rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -CryptonightR_template_end: - -ALIGN(64) -CryptonightR_template_double_part1: - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movq xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movq xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movq xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movq xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movq xmm0, rcx - mov r11d, 524288 - movq xmm10, rax - punpcklqdq xmm10, xmm0 - - movq xmm14, QWORD PTR [rsp+128] - movq xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -CryptonightR_template_double_mainloop: - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movq xmm0, r12 - mov ecx, ebx - movq xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movq xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm1 - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - movq rdx, xmm6 - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movq xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm1 - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movq rdi, xmm5 - movq rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movq xmm0, rsp - movq xmm1, rsi - movq xmm2, rdi - movq xmm11, rbp - movq xmm12, r15 - movq xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -CryptonightR_template_double_part2: - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r14, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r12, rax - - movq rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movq rsi, xmm1 - movq rdi, xmm2 - movq rbp, xmm11 - movq r15, xmm12 - movq rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movdqu xmm1, XMMWORD PTR [rcx+rsi] - pxor xmm6, xmm1 - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - pxor xmm6, xmm2 - paddq xmm2, xmm3 - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - pxor xmm6, xmm0 - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movq rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movq xmm0, rsp - movq xmm1, rbx - movq xmm2, rsi - movq xmm11, rdi - movq xmm12, rbp - movq xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movq xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -CryptonightR_template_double_part3: - - movq r15, xmm13 - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r13, rax - - movq rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movq rbx, xmm1 - movq rsi, xmm2 - movq rdi, xmm11 - movq rbp, xmm12 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - mov rdi, rcx - mov r8, rax - movdqu xmm1, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm1 - xor ebp, 48 - paddq xmm1, xmm8 - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm2 - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movq rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz CryptonightR_template_double_mainloop - -CryptonightR_template_double_part4: - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -CryptonightR_template_double_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template.inc deleted file mode 100644 index feea3949c2..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template.inc +++ /dev/null @@ -1,266 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightWOW_soft_aes_template_part1) -PUBLIC FN_PREFIX(CryptonightWOW_soft_aes_template_mainloop) -PUBLIC FN_PREFIX(CryptonightWOW_soft_aes_template_part2) -PUBLIC FN_PREFIX(CryptonightWOW_soft_aes_template_part3) -PUBLIC FN_PREFIX(CryptonightWOW_soft_aes_template_end) - -ALIGN(64) -FN_PREFIX(CryptonightWOW_soft_aes_template_part1): - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movq xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movq xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movq xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movq xmm10, QWORD PTR [r10+96] - movq xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movq xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movq xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -FN_PREFIX(CryptonightWOW_soft_aes_template_mainloop): - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movq xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movq xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movq r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movq rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movq rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - -FN_PREFIX(CryptonightWOW_soft_aes_template_part2): - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - paddq xmm1, xmm7 - movq xmm0, rax - movq xmm3, rdx - xor rax, QWORD PTR [r11+rcx+8] - xor rdx, QWORD PTR [rcx+r11] - punpcklqdq xmm3, xmm0 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm2, xmm3 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne FN_PREFIX(CryptonightWOW_soft_aes_template_mainloop) - -FN_PREFIX(CryptonightWOW_soft_aes_template_part3): - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -FN_PREFIX(CryptonightWOW_soft_aes_template_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template_win.inc deleted file mode 100644 index 6ebad99f63..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_soft_aes_template_win.inc +++ /dev/null @@ -1,266 +0,0 @@ -PUBLIC CryptonightWOW_soft_aes_template_part1 -PUBLIC CryptonightWOW_soft_aes_template_mainloop -PUBLIC CryptonightWOW_soft_aes_template_part2 -PUBLIC CryptonightWOW_soft_aes_template_part3 -PUBLIC CryptonightWOW_soft_aes_template_end - -ALIGN(64) -CryptonightWOW_soft_aes_template_part1: - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movq xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movq xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movq xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movq xmm10, QWORD PTR [r10+96] - movq xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movq xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movq xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -CryptonightWOW_soft_aes_template_mainloop: - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movq xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movq xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movq r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movq rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movq rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - -CryptonightWOW_soft_aes_template_part2: - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - paddq xmm1, xmm7 - movq xmm0, rax - movq xmm3, rdx - xor rax, QWORD PTR [r11+rcx+8] - xor rdx, QWORD PTR [rcx+r11] - punpcklqdq xmm3, xmm0 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm2, xmm3 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne CryptonightWOW_soft_aes_template_mainloop - -CryptonightWOW_soft_aes_template_part3: - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -CryptonightWOW_soft_aes_template_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template.inc deleted file mode 100644 index 7183a659f8..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template.inc +++ /dev/null @@ -1,486 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightWOW_template_part1) -PUBLIC FN_PREFIX(CryptonightWOW_template_mainloop) -PUBLIC FN_PREFIX(CryptonightWOW_template_part2) -PUBLIC FN_PREFIX(CryptonightWOW_template_part3) -PUBLIC FN_PREFIX(CryptonightWOW_template_end) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part1) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_mainloop) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part2) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part3) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part4) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_end) - -ALIGN(64) -FN_PREFIX(CryptonightWOW_template_part1): - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movq xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movq xmm0, r12 - movq xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movq xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -FN_PREFIX(CryptonightWOW_template_mainloop): - movdqa xmm5, XMMWORD PTR [r9+r11] - movq xmm0, r15 - movq xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - movd r10d, xmm5 - and r10d, 2097136 - - mov r12d, r9d - mov eax, r9d - xor r9d, 48 - xor r12d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movdqu xmm2, XMMWORD PTR [r12+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - paddq xmm0, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r12+r11], xmm0 - movq r12, xmm5 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - -FN_PREFIX(CryptonightWOW_template_part2): - mov rax, r13 - mul r12 - movq xmm0, rax - movq xmm3, rdx - punpcklqdq xmm3, xmm0 - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - xor rdx, QWORD PTR [r12+r11] - xor rax, QWORD PTR [r11+r12+8] - movdqa xmm2, XMMWORD PTR [r9+r11] - pxor xmm3, xmm2 - paddq xmm7, XMMWORD PTR [r10+r11] - paddq xmm1, xmm4 - paddq xmm3, xmm6 - movdqu XMMWORD PTR [r9+r11], xmm7 - movdqu XMMWORD PTR [r12+r11], xmm3 - movdqu XMMWORD PTR [r10+r11], xmm1 - - movdqa xmm7, xmm6 - add r15, rax - add rsp, rdx - xor r10, 48 - mov QWORD PTR [r10+r11], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [r10+r11+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz FN_PREFIX(CryptonightWOW_template_mainloop) - -FN_PREFIX(CryptonightWOW_template_part3): - movq rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -FN_PREFIX(CryptonightWOW_template_end): - -ALIGN(64) -FN_PREFIX(CryptonightWOW_template_double_part1): - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movq xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movq xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movq xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movq xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movq xmm0, rcx - mov r11d, 524288 - movq xmm10, rax - punpcklqdq xmm10, xmm0 - - movq xmm14, QWORD PTR [rsp+128] - movq xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -FN_PREFIX(CryptonightWOW_template_double_mainloop): - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movq xmm0, r12 - mov ecx, ebx - movq xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movq rdx, xmm6 - movq xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movq xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movq rdi, xmm5 - movq rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movq xmm0, rsp - movq xmm1, rsi - movq xmm2, rdi - movq xmm11, rbp - movq xmm12, r15 - movq xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -FN_PREFIX(CryptonightWOW_template_double_part2): - - movq rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movq rsi, xmm1 - movq rdi, xmm2 - movq rbp, xmm11 - movq r15, xmm12 - movq rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movq xmm1, rdx - movq xmm0, r8 - punpcklqdq xmm1, xmm0 - pxor xmm1, XMMWORD PTR [rcx+rsi] - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - xor rdx, QWORD PTR [rsi+rcx] - paddq xmm2, xmm3 - xor r8, QWORD PTR [rsi+rcx+8] - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movq rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movq xmm0, rsp - movq xmm1, rbx - movq xmm2, rsi - movq xmm11, rdi - movq xmm12, rbp - movq xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movq xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -FN_PREFIX(CryptonightWOW_template_double_part3): - - movq rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movq rbx, xmm1 - movq rsi, xmm2 - movq rdi, xmm11 - movq rbp, xmm12 - movq r15, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - movq xmm1, rdx - movq xmm0, rax - punpcklqdq xmm1, xmm0 - mov rdi, rcx - mov r8, rax - pxor xmm1, XMMWORD PTR [rbp+rcx] - xor ebp, 48 - paddq xmm1, xmm8 - xor r8, QWORD PTR [rbp+rcx+8] - xor rdx, QWORD PTR [rbp+rcx] - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movq rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz FN_PREFIX(CryptonightWOW_template_double_mainloop) - -FN_PREFIX(CryptonightWOW_template_double_part4): - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -FN_PREFIX(CryptonightWOW_template_double_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template_win.inc deleted file mode 100644 index c5652e2787..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/CryptonightWOW_template_win.inc +++ /dev/null @@ -1,486 +0,0 @@ -PUBLIC CryptonightWOW_template_part1 -PUBLIC CryptonightWOW_template_mainloop -PUBLIC CryptonightWOW_template_part2 -PUBLIC CryptonightWOW_template_part3 -PUBLIC CryptonightWOW_template_end -PUBLIC CryptonightWOW_template_double_part1 -PUBLIC CryptonightWOW_template_double_mainloop -PUBLIC CryptonightWOW_template_double_part2 -PUBLIC CryptonightWOW_template_double_part3 -PUBLIC CryptonightWOW_template_double_part4 -PUBLIC CryptonightWOW_template_double_end - -ALIGN(64) -CryptonightWOW_template_part1: - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movq xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movq xmm0, r12 - movq xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movq xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -CryptonightWOW_template_mainloop: - movdqa xmm5, XMMWORD PTR [r9+r11] - movq xmm0, r15 - movq xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - movd r10d, xmm5 - and r10d, 2097136 - - mov r12d, r9d - mov eax, r9d - xor r9d, 48 - xor r12d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movdqu xmm2, XMMWORD PTR [r12+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - paddq xmm0, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r12+r11], xmm0 - movq r12, xmm5 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - -CryptonightWOW_template_part2: - mov rax, r13 - mul r12 - movq xmm0, rax - movq xmm3, rdx - punpcklqdq xmm3, xmm0 - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - xor rdx, QWORD PTR [r12+r11] - xor rax, QWORD PTR [r11+r12+8] - movdqa xmm2, XMMWORD PTR [r9+r11] - pxor xmm3, xmm2 - paddq xmm7, XMMWORD PTR [r10+r11] - paddq xmm1, xmm4 - paddq xmm3, xmm6 - movdqu XMMWORD PTR [r9+r11], xmm7 - movdqu XMMWORD PTR [r12+r11], xmm3 - movdqu XMMWORD PTR [r10+r11], xmm1 - - movdqa xmm7, xmm6 - add r15, rax - add rsp, rdx - xor r10, 48 - mov QWORD PTR [r10+r11], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [r10+r11+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz CryptonightWOW_template_mainloop - -CryptonightWOW_template_part3: - movq rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -CryptonightWOW_template_end: - -ALIGN(64) -CryptonightWOW_template_double_part1: - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movq xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movq xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movq xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movq xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movq xmm0, rcx - mov r11d, 524288 - movq xmm10, rax - punpcklqdq xmm10, xmm0 - - movq xmm14, QWORD PTR [rsp+128] - movq xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -CryptonightWOW_template_double_mainloop: - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movq xmm0, r12 - mov ecx, ebx - movq xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movq rdx, xmm6 - movq xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movq xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movq rdi, xmm5 - movq rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movq xmm0, rsp - movq xmm1, rsi - movq xmm2, rdi - movq xmm11, rbp - movq xmm12, r15 - movq xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -CryptonightWOW_template_double_part2: - - movq rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movq rsi, xmm1 - movq rdi, xmm2 - movq rbp, xmm11 - movq r15, xmm12 - movq rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movq xmm1, rdx - movq xmm0, r8 - punpcklqdq xmm1, xmm0 - pxor xmm1, XMMWORD PTR [rcx+rsi] - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - xor rdx, QWORD PTR [rsi+rcx] - paddq xmm2, xmm3 - xor r8, QWORD PTR [rsi+rcx+8] - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movq rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movq xmm0, rsp - movq xmm1, rbx - movq xmm2, rsi - movq xmm11, rdi - movq xmm12, rbp - movq xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movq xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -CryptonightWOW_template_double_part3: - - movq rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movq rbx, xmm1 - movq rsi, xmm2 - movq rdi, xmm11 - movq rbp, xmm12 - movq r15, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - movq xmm1, rdx - movq xmm0, rax - punpcklqdq xmm1, xmm0 - mov rdi, rcx - mov r8, rax - pxor xmm1, XMMWORD PTR [rbp+rcx] - xor ebp, 48 - paddq xmm1, xmm8 - xor r8, QWORD PTR [rbp+rcx+8] - xor rdx, QWORD PTR [rbp+rcx] - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movq rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz CryptonightWOW_template_double_mainloop - -CryptonightWOW_template_double_part4: - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -CryptonightWOW_template_double_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_double_main_loop_sandybridge.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_double_main_loop_sandybridge.inc deleted file mode 100644 index aa5101a83a..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_double_main_loop_sandybridge.inc +++ /dev/null @@ -1,410 +0,0 @@ - mov rax, rsp - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 184 - - stmxcsr DWORD PTR [rsp+272] - mov DWORD PTR [rsp+276], 24448 - ldmxcsr DWORD PTR [rsp+276] - - mov r13, QWORD PTR [rcx+224] - mov r9, rdx - mov r10, QWORD PTR [rcx+32] - mov r8, rcx - xor r10, QWORD PTR [rcx] - mov r14d, 524288 - mov r11, QWORD PTR [rcx+40] - xor r11, QWORD PTR [rcx+8] - mov rsi, QWORD PTR [rdx+224] - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov rdi, QWORD PTR [r9+32] - xor rdi, QWORD PTR [r9] - mov rbp, QWORD PTR [r9+40] - xor rbp, QWORD PTR [r9+8] - movq xmm0, rdx - movaps XMMWORD PTR [rax-88], xmm6 - movaps XMMWORD PTR [rax-104], xmm7 - movaps XMMWORD PTR [rax-120], xmm8 - movaps XMMWORD PTR [rsp+112], xmm9 - movaps XMMWORD PTR [rsp+96], xmm10 - movaps XMMWORD PTR [rsp+80], xmm11 - movaps XMMWORD PTR [rsp+64], xmm12 - movaps XMMWORD PTR [rsp+48], xmm13 - movaps XMMWORD PTR [rsp+32], xmm14 - movaps XMMWORD PTR [rsp+16], xmm15 - mov rdx, r10 - movq xmm4, QWORD PTR [r8+96] - and edx, 2097136 - mov rax, QWORD PTR [rcx+48] - xorps xmm13, xmm13 - xor rax, QWORD PTR [rcx+16] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r8+72] - movq xmm5, QWORD PTR [r8+104] - movq xmm7, rax - - mov eax, 1 - shl rax, 52 - movq xmm14, rax - punpcklqdq xmm14, xmm14 - - mov eax, 1023 - shl rax, 52 - movq xmm12, rax - punpcklqdq xmm12, xmm12 - - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [r9+56] - xor rcx, QWORD PTR [r9+24] - movq xmm3, rax - mov rax, QWORD PTR [r9+48] - xor rax, QWORD PTR [r9+16] - punpcklqdq xmm3, xmm0 - movq xmm0, rcx - mov QWORD PTR [rsp], r13 - mov rcx, QWORD PTR [r9+88] - xor rcx, QWORD PTR [r9+72] - movq xmm6, rax - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - punpcklqdq xmm6, xmm0 - movq xmm0, rcx - mov QWORD PTR [rsp+256], r10 - mov rcx, rdi - mov QWORD PTR [rsp+264], r11 - movq xmm8, rax - and ecx, 2097136 - punpcklqdq xmm8, xmm0 - movq xmm0, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movq xmm0, QWORD PTR [r9+104] - lea r8, QWORD PTR [rcx+rsi] - movdqu xmm11, XMMWORD PTR [r8] - punpcklqdq xmm5, xmm0 - lea r9, QWORD PTR [rdx+r13] - movdqu xmm15, XMMWORD PTR [r9] - - ALIGN(64) -main_loop_double_sandybridge: - movdqu xmm9, xmm15 - mov eax, edx - mov ebx, edx - xor eax, 16 - xor ebx, 32 - xor edx, 48 - - movq xmm0, r11 - movq xmm2, r10 - punpcklqdq xmm2, xmm0 - aesenc xmm9, xmm2 - - movdqu xmm0, XMMWORD PTR [rax+r13] - movdqu xmm1, XMMWORD PTR [rbx+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [rbx+r13], xmm0 - movdqu xmm0, XMMWORD PTR [rdx+r13] - movdqu XMMWORD PTR [rdx+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [rax+r13], xmm0 - - movq r11, xmm9 - mov edx, r11d - and edx, 2097136 - movdqa xmm0, xmm9 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [r9], xmm0 - - lea rbx, QWORD PTR [rdx+r13] - mov r10, QWORD PTR [rdx+r13] - - movdqu xmm10, xmm11 - movq xmm0, rbp - movq xmm11, rdi - punpcklqdq xmm11, xmm0 - aesenc xmm10, xmm11 - - mov eax, ecx - mov r12d, ecx - xor eax, 16 - xor r12d, 32 - xor ecx, 48 - - movdqu xmm0, XMMWORD PTR [rax+rsi] - paddq xmm0, xmm6 - movdqu xmm1, XMMWORD PTR [r12+rsi] - movdqu XMMWORD PTR [r12+rsi], xmm0 - paddq xmm1, xmm11 - movdqu xmm0, XMMWORD PTR [rcx+rsi] - movdqu XMMWORD PTR [rcx+rsi], xmm1 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [rax+rsi], xmm0 - - movq rcx, xmm10 - and ecx, 2097136 - - movdqa xmm0, xmm10 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [r8], xmm0 - mov r12, QWORD PTR [rcx+rsi] - - mov r9, QWORD PTR [rbx+8] - - xor edx, 16 - mov r8d, edx - mov r15d, edx - - movq rdx, xmm5 - shl rdx, 32 - movq rax, xmm4 - xor rdx, rax - xor r10, rdx - mov rax, r10 - mul r11 - mov r11d, r8d - xor r11d, 48 - movq xmm0, rdx - xor rdx, [r11+r13] - movq xmm1, rax - xor rax, [r11+r13+8] - punpcklqdq xmm0, xmm1 - - pxor xmm0, XMMWORD PTR [r8+r13] - xor r8d, 32 - movdqu xmm1, XMMWORD PTR [r11+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [r11+r13], xmm0 - movdqu xmm0, XMMWORD PTR [r8+r13] - movdqu XMMWORD PTR [r8+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [r15+r13], xmm0 - - mov r11, QWORD PTR [rsp+256] - add r11, rdx - mov rdx, QWORD PTR [rsp+264] - add rdx, rax - mov QWORD PTR [rbx], r11 - xor r11, r10 - mov QWORD PTR [rbx+8], rdx - xor rdx, r9 - mov QWORD PTR [rsp+256], r11 - and r11d, 2097136 - mov QWORD PTR [rsp+264], rdx - mov QWORD PTR [rsp+8], r11 - lea r15, QWORD PTR [r11+r13] - movdqu xmm15, XMMWORD PTR [r11+r13] - lea r13, QWORD PTR [rsi+rcx] - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movaps xmm2, xmm13 - movq r10, xmm0 - psllq xmm5, 1 - shl r10, 32 - movdqa xmm0, xmm9 - psrldq xmm0, 8 - movdqa xmm1, xmm10 - movq r11, xmm0 - psrldq xmm1, 8 - movq r8, xmm1 - psrldq xmm4, 8 - movaps xmm0, xmm13 - movq rax, xmm4 - xor r10, rax - movaps xmm1, xmm13 - xor r10, r12 - lea rax, QWORD PTR [r11+1] - shr rax, 1 - movdqa xmm3, xmm9 - punpcklqdq xmm3, xmm10 - paddq xmm5, xmm3 - movq rdx, xmm5 - psrldq xmm5, 8 - cvtsi2sd xmm2, rax - or edx, -2147483647 - lea rax, QWORD PTR [r8+1] - shr rax, 1 - movq r9, xmm5 - cvtsi2sd xmm0, rax - or r9d, -2147483647 - cvtsi2sd xmm1, rdx - unpcklpd xmm2, xmm0 - movaps xmm0, xmm13 - cvtsi2sd xmm0, r9 - unpcklpd xmm1, xmm0 - divpd xmm2, xmm1 - paddq xmm2, xmm14 - cvttsd2si rax, xmm2 - psrldq xmm2, 8 - mov rbx, rax - imul rax, rdx - sub r11, rax - js div_fix_1_sandybridge -div_fix_1_ret_sandybridge: - - cvttsd2si rdx, xmm2 - mov rax, rdx - imul rax, r9 - movd xmm2, r11d - movd xmm4, ebx - sub r8, rax - js div_fix_2_sandybridge -div_fix_2_ret_sandybridge: - - movd xmm1, r8d - movd xmm0, edx - punpckldq xmm2, xmm1 - punpckldq xmm4, xmm0 - punpckldq xmm4, xmm2 - paddq xmm3, xmm4 - movdqa xmm0, xmm3 - psrlq xmm0, 12 - paddq xmm0, xmm12 - sqrtpd xmm1, xmm0 - movq r9, xmm1 - movdqa xmm5, xmm1 - psrlq xmm5, 19 - test r9, 524287 - je sqrt_fix_1_sandybridge -sqrt_fix_1_ret_sandybridge: - - movq r9, xmm10 - psrldq xmm1, 8 - movq r8, xmm1 - test r8, 524287 - je sqrt_fix_2_sandybridge -sqrt_fix_2_ret_sandybridge: - - mov r12d, ecx - mov r8d, ecx - xor r12d, 16 - xor r8d, 32 - xor ecx, 48 - mov rax, r10 - mul r9 - movq xmm0, rax - movq xmm3, rdx - punpcklqdq xmm3, xmm0 - - movdqu xmm0, XMMWORD PTR [r12+rsi] - pxor xmm0, xmm3 - movdqu xmm1, XMMWORD PTR [r8+rsi] - xor rdx, [r8+rsi] - xor rax, [r8+rsi+8] - movdqu xmm3, XMMWORD PTR [rcx+rsi] - paddq xmm0, xmm6 - paddq xmm1, xmm11 - paddq xmm3, xmm8 - movdqu XMMWORD PTR [r8+rsi], xmm0 - movdqu XMMWORD PTR [rcx+rsi], xmm1 - movdqu XMMWORD PTR [r12+rsi], xmm3 - - add rdi, rdx - mov QWORD PTR [r13], rdi - xor rdi, r10 - mov ecx, edi - and ecx, 2097136 - lea r8, QWORD PTR [rcx+rsi] - - mov rdx, QWORD PTR [r13+8] - add rbp, rax - mov QWORD PTR [r13+8], rbp - movdqu xmm11, XMMWORD PTR [rcx+rsi] - xor rbp, rdx - mov r13, QWORD PTR [rsp] - movdqa xmm3, xmm7 - mov rdx, QWORD PTR [rsp+8] - movdqa xmm8, xmm6 - mov r10, QWORD PTR [rsp+256] - movdqa xmm7, xmm9 - mov r11, QWORD PTR [rsp+264] - movdqa xmm6, xmm10 - mov r9, r15 - dec r14d - jne main_loop_double_sandybridge - - ldmxcsr DWORD PTR [rsp+272] - movaps xmm13, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+184] - movaps xmm6, XMMWORD PTR [r11-24] - movaps xmm7, XMMWORD PTR [r11-40] - movaps xmm8, XMMWORD PTR [r11-56] - movaps xmm9, XMMWORD PTR [r11-72] - movaps xmm10, XMMWORD PTR [r11-88] - movaps xmm11, XMMWORD PTR [r11-104] - movaps xmm12, XMMWORD PTR [r11-120] - movaps xmm14, XMMWORD PTR [rsp+32] - movaps xmm15, XMMWORD PTR [rsp+16] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - jmp cnv2_double_mainloop_asm_sandybridge_endp - -div_fix_1_sandybridge: - dec rbx - add r11, rdx - jmp div_fix_1_ret_sandybridge - -div_fix_2_sandybridge: - dec rdx - add r8, r9 - jmp div_fix_2_ret_sandybridge - -sqrt_fix_1_sandybridge: - movq r8, xmm3 - movdqa xmm0, xmm5 - psrldq xmm0, 8 - dec r9 - mov r11d, -1022 - shl r11, 32 - mov rax, r9 - shr r9, 19 - shr rax, 20 - mov rdx, r9 - sub rdx, rax - lea rdx, [rdx+r11+1] - add rax, r11 - imul rdx, rax - sub rdx, r8 - adc r9, 0 - movq xmm5, r9 - punpcklqdq xmm5, xmm0 - jmp sqrt_fix_1_ret_sandybridge - -sqrt_fix_2_sandybridge: - psrldq xmm3, 8 - movq r11, xmm3 - dec r8 - mov ebx, -1022 - shl rbx, 32 - mov rax, r8 - shr r8, 19 - shr rax, 20 - mov rdx, r8 - sub rdx, rax - lea rdx, [rdx+rbx+1] - add rax, rbx - imul rdx, rax - sub rdx, r11 - adc r8, 0 - movq xmm0, r8 - punpcklqdq xmm5, xmm0 - jmp sqrt_fix_2_ret_sandybridge - -cnv2_double_mainloop_asm_sandybridge_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_bulldozer.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_bulldozer.inc deleted file mode 100644 index c764501db9..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_bulldozer.inc +++ /dev/null @@ -1,180 +0,0 @@ - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 64 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov ebp, 524288 - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movq xmm3, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movq xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - mov rdi, QWORD PTR [r9+104] - and r10d, 2097136 - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm4, rax - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - xorps xmm8, xmm8 - mov ax, 1023 - shl rax, 52 - movq xmm7, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm3, xmm0 - movq xmm0, rcx - punpcklqdq xmm4, xmm0 - - ALIGN(64) -cnv2_main_loop_bulldozer: - movdqa xmm5, XMMWORD PTR [r10+rbx] - movq xmm6, r8 - pinsrq xmm6, r11, 1 - lea rdx, QWORD PTR [r10+rbx] - lea r9, QWORD PTR [rdi+rdi] - shl rdi, 32 - - mov ecx, r10d - mov eax, r10d - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - aesenc xmm5, xmm6 - movdqa xmm2, XMMWORD PTR [rcx+rbx] - movdqa xmm1, XMMWORD PTR [rax+rbx] - movdqa xmm0, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - paddq xmm0, xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm0 - movdqa XMMWORD PTR [rax+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movaps xmm1, xmm8 - mov rsi, r15 - xor rsi, rdi - - mov edi, 1023 - shl rdi, 52 - - movq r14, xmm5 - pextrq rax, xmm5, 1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm3 - mov r10, r14 - and r10d, 2097136 - movdqa XMMWORD PTR [rdx], xmm0 - xor rsi, QWORD PTR [r10+rbx] - lea r12, QWORD PTR [r10+rbx] - mov r13, QWORD PTR [r10+rbx+8] - - add r9d, r14d - or r9d, -2147483647 - xor edx, edx - div r9 - mov eax, eax - shl rdx, 32 - lea r15, [rax+rdx] - lea rax, [r14+r15] - shr rax, 12 - add rax, rdi - movq xmm0, rax - sqrtsd xmm1, xmm0 - movq rdi, xmm1 - test rdi, 524287 - je sqrt_fixup_bulldozer - shr rdi, 19 - -sqrt_fixup_bulldozer_ret: - mov rax, rsi - mul r14 - movq xmm1, rax - movq xmm0, rdx - punpcklqdq xmm0, xmm1 - - mov r9d, r10d - mov ecx, r10d - xor r9d, 16 - xor ecx, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [rcx+rbx] - xor rdx, [rcx+rbx] - xor rax, [rcx+rbx+8] - movdqa xmm2, XMMWORD PTR [r9+rbx] - pxor xmm2, xmm0 - paddq xmm4, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - movdqa XMMWORD PTR [r9+rbx], xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movdqa xmm4, xmm3 - add r8, rdx - add r11, rax - mov QWORD PTR [r12], r8 - xor r8, rsi - mov QWORD PTR [r12+8], r11 - mov r10, r8 - xor r11, r13 - and r10d, 2097136 - movdqa xmm3, xmm5 - dec ebp - jne cnv2_main_loop_bulldozer - - ldmxcsr DWORD PTR [rsp] - movaps xmm6, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+64] - mov rbx, QWORD PTR [r11+56] - mov rbp, QWORD PTR [r11+64] - mov rsi, QWORD PTR [r11+72] - movaps xmm8, XMMWORD PTR [r11-48] - movaps xmm7, XMMWORD PTR [rsp+32] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - jmp cnv2_main_loop_bulldozer_endp - -sqrt_fixup_bulldozer: - movq r9, xmm5 - add r9, r15 - dec rdi - mov edx, -1022 - shl rdx, 32 - mov rax, rdi - shr rdi, 19 - shr rax, 20 - mov rcx, rdi - sub rcx, rax - lea rcx, [rcx+rdx+1] - add rax, rdx - imul rcx, rax - sub rcx, r9 - adc rdi, 0 - jmp sqrt_fixup_bulldozer_ret - -cnv2_main_loop_bulldozer_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ivybridge.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ivybridge.inc deleted file mode 100644 index 06f1d28be0..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ivybridge.inc +++ /dev/null @@ -1,186 +0,0 @@ - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 80 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov esi, 524288 - mov r8, QWORD PTR [rcx+32] - mov r13d, -2147483647 - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movq xmm4, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movq xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - movq xmm3, QWORD PTR [r9+104] - movaps XMMWORD PTR [rsp+64], xmm6 - movaps XMMWORD PTR [rsp+48], xmm7 - movaps XMMWORD PTR [rsp+32], xmm8 - and r10d, 2097136 - movq xmm5, rax - - xor eax, eax - mov QWORD PTR [rsp+16], rax - - mov ax, 1023 - shl rax, 52 - movq xmm8, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movq xmm0, rcx - punpcklqdq xmm5, xmm0 - movdqu xmm6, XMMWORD PTR [r10+rbx] - - ALIGN(64) -main_loop_ivybridge: - lea rdx, QWORD PTR [r10+rbx] - mov ecx, r10d - mov eax, r10d - mov rdi, r15 - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - movq xmm0, r11 - movq xmm7, r8 - punpcklqdq xmm7, xmm0 - aesenc xmm6, xmm7 - movq rbp, xmm6 - mov r9, rbp - and r9d, 2097136 - movdqu xmm2, XMMWORD PTR [rcx+rbx] - movdqu xmm1, XMMWORD PTR [rax+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm1, xmm7 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [rax+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - mov r10, r9 - xor r10d, 32 - movq rcx, xmm3 - mov rax, rcx - shl rax, 32 - xor rdi, rax - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [rdx], xmm0 - xor rdi, QWORD PTR [r9+rbx] - lea r14, QWORD PTR [r9+rbx] - mov r12, QWORD PTR [r14+8] - xor edx, edx - lea r9d, DWORD PTR [ecx+ecx] - add r9d, ebp - movdqa xmm0, xmm6 - psrldq xmm0, 8 - or r9d, r13d - movq rax, xmm0 - div r9 - xorps xmm3, xmm3 - mov eax, eax - shl rdx, 32 - add rdx, rax - lea r9, QWORD PTR [rdx+rbp] - mov r15, rdx - mov rax, r9 - shr rax, 12 - movq xmm0, rax - paddq xmm0, xmm8 - sqrtsd xmm3, xmm0 - psubq xmm3, XMMWORD PTR [rsp+16] - movq rdx, xmm3 - test edx, 524287 - je sqrt_fixup_ivybridge - psrlq xmm3, 19 -sqrt_fixup_ivybridge_ret: - - mov ecx, r10d - mov rax, rdi - mul rbp - movq xmm2, rdx - xor rdx, [rcx+rbx] - add r8, rdx - mov QWORD PTR [r14], r8 - xor r8, rdi - mov edi, r8d - and edi, 2097136 - movq xmm0, rax - xor rax, [rcx+rbx+8] - add r11, rax - mov QWORD PTR [r14+8], r11 - punpcklqdq xmm2, xmm0 - - mov r9d, r10d - xor r9d, 48 - xor r10d, 16 - pxor xmm2, XMMWORD PTR [r9+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm5 - movdqu xmm1, XMMWORD PTR [rcx+rbx] - paddq xmm2, xmm4 - paddq xmm1, xmm7 - movdqa xmm5, xmm4 - movdqu XMMWORD PTR [r9+rbx], xmm0 - movdqa xmm4, xmm6 - movdqu XMMWORD PTR [rcx+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - movdqu xmm6, [rdi+rbx] - mov r10d, edi - xor r11, r12 - dec rsi - jne main_loop_ivybridge - - ldmxcsr DWORD PTR [rsp] - mov rbx, QWORD PTR [rsp+160] - movaps xmm6, XMMWORD PTR [rsp+64] - movaps xmm7, XMMWORD PTR [rsp+48] - movaps xmm8, XMMWORD PTR [rsp+32] - add rsp, 80 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - jmp cnv2_main_loop_ivybridge_endp - -sqrt_fixup_ivybridge: - dec rdx - mov r13d, -1022 - shl r13, 32 - mov rax, rdx - shr rdx, 19 - shr rax, 20 - mov rcx, rdx - sub rcx, rax - add rax, r13 - not r13 - sub rcx, r13 - mov r13d, -2147483647 - imul rcx, rax - sub rcx, r9 - adc rdx, 0 - movq xmm3, rdx - jmp sqrt_fixup_ivybridge_ret - -cnv2_main_loop_ivybridge_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ryzen.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ryzen.inc deleted file mode 100644 index 5dbf5917f3..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_main_loop_ryzen.inc +++ /dev/null @@ -1,179 +0,0 @@ - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 64 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov ebp, 524288 - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movq xmm3, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movq xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - mov rdi, QWORD PTR [r9+104] - and r10d, 2097136 - movaps XMMWORD PTR [rsp+48], xmm6 - movq xmm4, rax - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - xorps xmm8, xmm8 - mov ax, 1023 - shl rax, 52 - movq xmm7, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm3, xmm0 - movq xmm0, rcx - punpcklqdq xmm4, xmm0 - - ALIGN(64) -main_loop_ryzen: - movdqa xmm5, XMMWORD PTR [r10+rbx] - movq xmm0, r11 - movq xmm6, r8 - punpcklqdq xmm6, xmm0 - lea rdx, QWORD PTR [r10+rbx] - lea r9, QWORD PTR [rdi+rdi] - shl rdi, 32 - - mov ecx, r10d - mov eax, r10d - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - aesenc xmm5, xmm6 - movdqa xmm2, XMMWORD PTR [rcx+rbx] - movdqa xmm1, XMMWORD PTR [rax+rbx] - movdqa xmm0, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - paddq xmm0, xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm0 - movdqa XMMWORD PTR [rax+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movaps xmm1, xmm8 - mov rsi, r15 - xor rsi, rdi - movq r14, xmm5 - movdqa xmm0, xmm5 - pxor xmm0, xmm3 - mov r10, r14 - and r10d, 2097136 - movdqa XMMWORD PTR [rdx], xmm0 - xor rsi, QWORD PTR [r10+rbx] - lea r12, QWORD PTR [r10+rbx] - mov r13, QWORD PTR [r10+rbx+8] - - add r9d, r14d - or r9d, -2147483647 - xor edx, edx - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movq rax, xmm0 - - div r9 - movq xmm0, rax - movq xmm1, rdx - punpckldq xmm0, xmm1 - movq r15, xmm0 - paddq xmm0, xmm5 - movdqa xmm2, xmm0 - psrlq xmm0, 12 - paddq xmm0, xmm7 - sqrtsd xmm1, xmm0 - movq rdi, xmm1 - test rdi, 524287 - je sqrt_fixup_ryzen - shr rdi, 19 - -sqrt_fixup_ryzen_ret: - mov rax, rsi - mul r14 - movq xmm1, rax - movq xmm0, rdx - punpcklqdq xmm0, xmm1 - - mov r9d, r10d - mov ecx, r10d - xor r9d, 16 - xor ecx, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [rcx+rbx] - xor rdx, [rcx+rbx] - xor rax, [rcx+rbx+8] - movdqa xmm2, XMMWORD PTR [r9+rbx] - pxor xmm2, xmm0 - paddq xmm4, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - movdqa XMMWORD PTR [r9+rbx], xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movdqa xmm4, xmm3 - add r8, rdx - add r11, rax - mov QWORD PTR [r12], r8 - xor r8, rsi - mov QWORD PTR [r12+8], r11 - mov r10, r8 - xor r11, r13 - and r10d, 2097136 - movdqa xmm3, xmm5 - dec ebp - jne main_loop_ryzen - - ldmxcsr DWORD PTR [rsp] - movaps xmm6, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+64] - mov rbx, QWORD PTR [r11+56] - mov rbp, QWORD PTR [r11+64] - mov rsi, QWORD PTR [r11+72] - movaps xmm8, XMMWORD PTR [r11-48] - movaps xmm7, XMMWORD PTR [rsp+32] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - jmp cnv2_main_loop_ryzen_endp - -sqrt_fixup_ryzen: - movq r9, xmm2 - dec rdi - mov edx, -1022 - shl rdx, 32 - mov rax, rdi - shr rdi, 19 - shr rax, 20 - mov rcx, rdi - sub rcx, rax - lea rcx, [rcx+rdx+1] - add rax, rdx - imul rcx, rax - sub rcx, r9 - adc rdi, 0 - jmp sqrt_fixup_ryzen_ret - -cnv2_main_loop_ryzen_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_double_main_loop.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_double_main_loop.inc deleted file mode 100644 index d2d871732d..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_double_main_loop.inc +++ /dev/null @@ -1,410 +0,0 @@ - mov rax, rsp - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 184 - - stmxcsr DWORD PTR [rsp+272] - mov DWORD PTR [rsp+276], 24448 - ldmxcsr DWORD PTR [rsp+276] - - mov r13, QWORD PTR [rcx+224] - mov r9, rdx - mov r10, QWORD PTR [rcx+32] - mov r8, rcx - xor r10, QWORD PTR [rcx] - mov r14d, 393216 - mov r11, QWORD PTR [rcx+40] - xor r11, QWORD PTR [rcx+8] - mov rsi, QWORD PTR [rdx+224] - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov rdi, QWORD PTR [r9+32] - xor rdi, QWORD PTR [r9] - mov rbp, QWORD PTR [r9+40] - xor rbp, QWORD PTR [r9+8] - movq xmm0, rdx - movaps XMMWORD PTR [rax-88], xmm6 - movaps XMMWORD PTR [rax-104], xmm7 - movaps XMMWORD PTR [rax-120], xmm8 - movaps XMMWORD PTR [rsp+112], xmm9 - movaps XMMWORD PTR [rsp+96], xmm10 - movaps XMMWORD PTR [rsp+80], xmm11 - movaps XMMWORD PTR [rsp+64], xmm12 - movaps XMMWORD PTR [rsp+48], xmm13 - movaps XMMWORD PTR [rsp+32], xmm14 - movaps XMMWORD PTR [rsp+16], xmm15 - mov rdx, r10 - movq xmm4, QWORD PTR [r8+96] - and edx, 2097136 - mov rax, QWORD PTR [rcx+48] - xorps xmm13, xmm13 - xor rax, QWORD PTR [rcx+16] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r8+72] - movq xmm5, QWORD PTR [r8+104] - movq xmm7, rax - - mov eax, 1 - shl rax, 52 - movq xmm14, rax - punpcklqdq xmm14, xmm14 - - mov eax, 1023 - shl rax, 52 - movq xmm12, rax - punpcklqdq xmm12, xmm12 - - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - punpcklqdq xmm7, xmm0 - movq xmm0, rcx - mov rcx, QWORD PTR [r9+56] - xor rcx, QWORD PTR [r9+24] - movq xmm3, rax - mov rax, QWORD PTR [r9+48] - xor rax, QWORD PTR [r9+16] - punpcklqdq xmm3, xmm0 - movq xmm0, rcx - mov QWORD PTR [rsp], r13 - mov rcx, QWORD PTR [r9+88] - xor rcx, QWORD PTR [r9+72] - movq xmm6, rax - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - punpcklqdq xmm6, xmm0 - movq xmm0, rcx - mov QWORD PTR [rsp+256], r10 - mov rcx, rdi - mov QWORD PTR [rsp+264], r11 - movq xmm8, rax - and ecx, 2097136 - punpcklqdq xmm8, xmm0 - movq xmm0, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movq xmm0, QWORD PTR [r9+104] - lea r8, QWORD PTR [rcx+rsi] - movdqu xmm11, XMMWORD PTR [r8] - punpcklqdq xmm5, xmm0 - lea r9, QWORD PTR [rdx+r13] - movdqu xmm15, XMMWORD PTR [r9] - - ALIGN(64) -rwz_main_loop_double: - movdqu xmm9, xmm15 - mov eax, edx - mov ebx, edx - xor eax, 16 - xor ebx, 32 - xor edx, 48 - - movq xmm0, r11 - movq xmm2, r10 - punpcklqdq xmm2, xmm0 - aesenc xmm9, xmm2 - - movdqu xmm0, XMMWORD PTR [rdx+r13] - movdqu xmm1, XMMWORD PTR [rbx+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [rbx+r13], xmm0 - movdqu xmm0, XMMWORD PTR [rax+r13] - movdqu XMMWORD PTR [rdx+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [rax+r13], xmm0 - - movq r11, xmm9 - mov edx, r11d - and edx, 2097136 - movdqa xmm0, xmm9 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [r9], xmm0 - - lea rbx, QWORD PTR [rdx+r13] - mov r10, QWORD PTR [rdx+r13] - - movdqu xmm10, xmm11 - movq xmm0, rbp - movq xmm11, rdi - punpcklqdq xmm11, xmm0 - aesenc xmm10, xmm11 - - mov eax, ecx - mov r12d, ecx - xor eax, 16 - xor r12d, 32 - xor ecx, 48 - - movdqu xmm0, XMMWORD PTR [rcx+rsi] - paddq xmm0, xmm6 - movdqu xmm1, XMMWORD PTR [r12+rsi] - movdqu XMMWORD PTR [r12+rsi], xmm0 - paddq xmm1, xmm11 - movdqu xmm0, XMMWORD PTR [rax+rsi] - movdqu XMMWORD PTR [rcx+rsi], xmm1 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [rax+rsi], xmm0 - - movq rcx, xmm10 - and ecx, 2097136 - - movdqa xmm0, xmm10 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [r8], xmm0 - mov r12, QWORD PTR [rcx+rsi] - - mov r9, QWORD PTR [rbx+8] - - xor edx, 16 - mov r8d, edx - mov r15d, edx - - movq rdx, xmm5 - shl rdx, 32 - movq rax, xmm4 - xor rdx, rax - xor r10, rdx - mov rax, r10 - mul r11 - mov r11d, r8d - xor r11d, 48 - movq xmm0, rdx - xor rdx, [r11+r13] - movq xmm1, rax - xor rax, [r11+r13+8] - punpcklqdq xmm0, xmm1 - - pxor xmm0, XMMWORD PTR [r8+r13] - movdqu xmm1, XMMWORD PTR [r11+r13] - paddq xmm0, xmm3 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [r8+r13], xmm0 - xor r8d, 32 - movdqu xmm0, XMMWORD PTR [r8+r13] - movdqu XMMWORD PTR [r8+r13], xmm1 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r11+r13], xmm0 - - mov r11, QWORD PTR [rsp+256] - add r11, rdx - mov rdx, QWORD PTR [rsp+264] - add rdx, rax - mov QWORD PTR [rbx], r11 - xor r11, r10 - mov QWORD PTR [rbx+8], rdx - xor rdx, r9 - mov QWORD PTR [rsp+256], r11 - and r11d, 2097136 - mov QWORD PTR [rsp+264], rdx - mov QWORD PTR [rsp+8], r11 - lea r15, QWORD PTR [r11+r13] - movdqu xmm15, XMMWORD PTR [r11+r13] - lea r13, QWORD PTR [rsi+rcx] - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movaps xmm2, xmm13 - movq r10, xmm0 - psllq xmm5, 1 - shl r10, 32 - movdqa xmm0, xmm9 - psrldq xmm0, 8 - movdqa xmm1, xmm10 - movq r11, xmm0 - psrldq xmm1, 8 - movq r8, xmm1 - psrldq xmm4, 8 - movaps xmm0, xmm13 - movq rax, xmm4 - xor r10, rax - movaps xmm1, xmm13 - xor r10, r12 - lea rax, QWORD PTR [r11+1] - shr rax, 1 - movdqa xmm3, xmm9 - punpcklqdq xmm3, xmm10 - paddq xmm5, xmm3 - movq rdx, xmm5 - psrldq xmm5, 8 - cvtsi2sd xmm2, rax - or edx, -2147483647 - lea rax, QWORD PTR [r8+1] - shr rax, 1 - movq r9, xmm5 - cvtsi2sd xmm0, rax - or r9d, -2147483647 - cvtsi2sd xmm1, rdx - unpcklpd xmm2, xmm0 - movaps xmm0, xmm13 - cvtsi2sd xmm0, r9 - unpcklpd xmm1, xmm0 - divpd xmm2, xmm1 - paddq xmm2, xmm14 - cvttsd2si rax, xmm2 - psrldq xmm2, 8 - mov rbx, rax - imul rax, rdx - sub r11, rax - js rwz_div_fix_1 -rwz_div_fix_1_ret: - - cvttsd2si rdx, xmm2 - mov rax, rdx - imul rax, r9 - movd xmm2, r11d - movd xmm4, ebx - sub r8, rax - js rwz_div_fix_2 -rwz_div_fix_2_ret: - - movd xmm1, r8d - movd xmm0, edx - punpckldq xmm2, xmm1 - punpckldq xmm4, xmm0 - punpckldq xmm4, xmm2 - paddq xmm3, xmm4 - movdqa xmm0, xmm3 - psrlq xmm0, 12 - paddq xmm0, xmm12 - sqrtpd xmm1, xmm0 - movq r9, xmm1 - movdqa xmm5, xmm1 - psrlq xmm5, 19 - test r9, 524287 - je rwz_sqrt_fix_1 -rwz_sqrt_fix_1_ret: - - movq r9, xmm10 - psrldq xmm1, 8 - movq r8, xmm1 - test r8, 524287 - je rwz_sqrt_fix_2 -rwz_sqrt_fix_2_ret: - - mov r12d, ecx - mov r8d, ecx - xor r12d, 16 - xor r8d, 32 - xor ecx, 48 - mov rax, r10 - mul r9 - movq xmm0, rax - movq xmm3, rdx - punpcklqdq xmm3, xmm0 - - movdqu xmm0, XMMWORD PTR [r12+rsi] - pxor xmm0, xmm3 - movdqu xmm1, XMMWORD PTR [r8+rsi] - xor rdx, [r8+rsi] - xor rax, [r8+rsi+8] - movdqu xmm3, XMMWORD PTR [rcx+rsi] - paddq xmm3, xmm6 - paddq xmm1, xmm11 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [r8+rsi], xmm3 - movdqu XMMWORD PTR [rcx+rsi], xmm1 - movdqu XMMWORD PTR [r12+rsi], xmm0 - - add rdi, rdx - mov QWORD PTR [r13], rdi - xor rdi, r10 - mov ecx, edi - and ecx, 2097136 - lea r8, QWORD PTR [rcx+rsi] - - mov rdx, QWORD PTR [r13+8] - add rbp, rax - mov QWORD PTR [r13+8], rbp - movdqu xmm11, XMMWORD PTR [rcx+rsi] - xor rbp, rdx - mov r13, QWORD PTR [rsp] - movdqa xmm3, xmm7 - mov rdx, QWORD PTR [rsp+8] - movdqa xmm8, xmm6 - mov r10, QWORD PTR [rsp+256] - movdqa xmm7, xmm9 - mov r11, QWORD PTR [rsp+264] - movdqa xmm6, xmm10 - mov r9, r15 - dec r14d - jne rwz_main_loop_double - - ldmxcsr DWORD PTR [rsp+272] - movaps xmm13, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+184] - movaps xmm6, XMMWORD PTR [r11-24] - movaps xmm7, XMMWORD PTR [r11-40] - movaps xmm8, XMMWORD PTR [r11-56] - movaps xmm9, XMMWORD PTR [r11-72] - movaps xmm10, XMMWORD PTR [r11-88] - movaps xmm11, XMMWORD PTR [r11-104] - movaps xmm12, XMMWORD PTR [r11-120] - movaps xmm14, XMMWORD PTR [rsp+32] - movaps xmm15, XMMWORD PTR [rsp+16] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - jmp rwz_cnv2_double_mainloop_asm_endp - -rwz_div_fix_1: - dec rbx - add r11, rdx - jmp rwz_div_fix_1_ret - -rwz_div_fix_2: - dec rdx - add r8, r9 - jmp rwz_div_fix_2_ret - -rwz_sqrt_fix_1: - movq r8, xmm3 - movdqa xmm0, xmm5 - psrldq xmm0, 8 - dec r9 - mov r11d, -1022 - shl r11, 32 - mov rax, r9 - shr r9, 19 - shr rax, 20 - mov rdx, r9 - sub rdx, rax - lea rdx, [rdx+r11+1] - add rax, r11 - imul rdx, rax - sub rdx, r8 - adc r9, 0 - movq xmm5, r9 - punpcklqdq xmm5, xmm0 - jmp rwz_sqrt_fix_1_ret - -rwz_sqrt_fix_2: - psrldq xmm3, 8 - movq r11, xmm3 - dec r8 - mov ebx, -1022 - shl rbx, 32 - mov rax, r8 - shr r8, 19 - shr rax, 20 - mov rdx, r8 - sub rdx, rax - lea rdx, [rdx+rbx+1] - add rax, rbx - imul rdx, rax - sub rdx, r11 - adc r8, 0 - movq xmm0, r8 - punpcklqdq xmm5, xmm0 - jmp rwz_sqrt_fix_2_ret - -rwz_cnv2_double_mainloop_asm_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_main_loop.inc b/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_main_loop.inc deleted file mode 100644 index 021f787e33..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn2/cnv2_rwz_main_loop.inc +++ /dev/null @@ -1,186 +0,0 @@ - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 80 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov esi, 393216 - mov r8, QWORD PTR [rcx+32] - mov r13d, -2147483647 - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movq xmm4, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movq xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - movq xmm3, QWORD PTR [r9+104] - movaps XMMWORD PTR [rsp+64], xmm6 - movaps XMMWORD PTR [rsp+48], xmm7 - movaps XMMWORD PTR [rsp+32], xmm8 - and r10d, 2097136 - movq xmm5, rax - - xor eax, eax - mov QWORD PTR [rsp+16], rax - - mov ax, 1023 - shl rax, 52 - movq xmm8, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movq xmm0, rcx - punpcklqdq xmm5, xmm0 - movdqu xmm6, XMMWORD PTR [r10+rbx] - - ALIGN(64) -rwz_main_loop: - lea rdx, QWORD PTR [r10+rbx] - mov ecx, r10d - mov eax, r10d - mov rdi, r15 - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - movq xmm0, r11 - movq xmm7, r8 - punpcklqdq xmm7, xmm0 - aesenc xmm6, xmm7 - movq rbp, xmm6 - mov r9, rbp - and r9d, 2097136 - movdqu xmm0, XMMWORD PTR [rcx+rbx] - movdqu xmm1, XMMWORD PTR [rax+rbx] - movdqu xmm2, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm5 - paddq xmm1, xmm7 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [rax+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - mov r10, r9 - xor r10d, 32 - movq rcx, xmm3 - mov rax, rcx - shl rax, 32 - xor rdi, rax - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [rdx], xmm0 - xor rdi, QWORD PTR [r9+rbx] - lea r14, QWORD PTR [r9+rbx] - mov r12, QWORD PTR [r14+8] - xor edx, edx - lea r9d, DWORD PTR [ecx+ecx] - add r9d, ebp - movdqa xmm0, xmm6 - psrldq xmm0, 8 - or r9d, r13d - movq rax, xmm0 - div r9 - xorps xmm3, xmm3 - mov eax, eax - shl rdx, 32 - add rdx, rax - lea r9, QWORD PTR [rdx+rbp] - mov r15, rdx - mov rax, r9 - shr rax, 12 - movq xmm0, rax - paddq xmm0, xmm8 - sqrtsd xmm3, xmm0 - psubq xmm3, XMMWORD PTR [rsp+16] - movq rdx, xmm3 - test edx, 524287 - je rwz_sqrt_fixup - psrlq xmm3, 19 -rwz_sqrt_fixup_ret: - - mov ecx, r10d - mov rax, rdi - mul rbp - movq xmm2, rdx - xor rdx, [rcx+rbx] - add r8, rdx - mov QWORD PTR [r14], r8 - xor r8, rdi - mov edi, r8d - and edi, 2097136 - movq xmm0, rax - xor rax, [rcx+rbx+8] - add r11, rax - mov QWORD PTR [r14+8], r11 - punpcklqdq xmm2, xmm0 - - mov r9d, r10d - xor r9d, 48 - xor r10d, 16 - pxor xmm2, XMMWORD PTR [r9+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm4 - movdqu xmm1, XMMWORD PTR [rcx+rbx] - paddq xmm2, xmm5 - paddq xmm1, xmm7 - movdqa xmm5, xmm4 - movdqu XMMWORD PTR [r9+rbx], xmm2 - movdqa xmm4, xmm6 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [r10+rbx], xmm1 - movdqu xmm6, [rdi+rbx] - mov r10d, edi - xor r11, r12 - dec rsi - jne rwz_main_loop - - ldmxcsr DWORD PTR [rsp] - mov rbx, QWORD PTR [rsp+160] - movaps xmm6, XMMWORD PTR [rsp+64] - movaps xmm7, XMMWORD PTR [rsp+48] - movaps xmm8, XMMWORD PTR [rsp+32] - add rsp, 80 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - jmp cnv2_rwz_main_loop_endp - -rwz_sqrt_fixup: - dec rdx - mov r13d, -1022 - shl r13, 32 - mov rax, rdx - shr rdx, 19 - shr rax, 20 - mov rcx, rdx - sub rcx, rax - add rax, r13 - not r13 - sub rcx, r13 - mov r13d, -2147483647 - imul rcx, rax - sub rcx, r9 - adc rdx, 0 - movq xmm3, rdx - jmp rwz_sqrt_fixup_ret - -cnv2_rwz_main_loop_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/cn_main_loop.S b/src/Native/libcryptonight/xmrig/crypto/asm/cn_main_loop.S deleted file mode 100644 index c2c08739a5..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/cn_main_loop.S +++ /dev/null @@ -1,74 +0,0 @@ -#ifdef __APPLE__ -# define ALIGN(x) .align 6 -#else -# define ALIGN(x) .align 64 -#endif -.intel_syntax noprefix -#ifdef __APPLE__ -# define FN_PREFIX(fn) _ ## fn -.text -#else -# define FN_PREFIX(fn) fn -.section .text -#endif -.global FN_PREFIX(cnv2_mainloop_ivybridge_asm) -.global FN_PREFIX(cnv2_mainloop_ryzen_asm) -.global FN_PREFIX(cnv2_mainloop_bulldozer_asm) -.global FN_PREFIX(cnv2_double_mainloop_sandybridge_asm) -.global FN_PREFIX(cnv2_rwz_mainloop_asm) -.global FN_PREFIX(cnv2_rwz_double_mainloop_asm) - -ALIGN(64) -FN_PREFIX(cnv2_mainloop_ivybridge_asm): - sub rsp, 48 - mov rcx, rdi - #include "cn2/cnv2_main_loop_ivybridge.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 - -ALIGN(64) -FN_PREFIX(cnv2_mainloop_ryzen_asm): - sub rsp, 48 - mov rcx, rdi - #include "cn2/cnv2_main_loop_ryzen.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 - -ALIGN(64) -FN_PREFIX(cnv2_mainloop_bulldozer_asm): - sub rsp, 48 - mov rcx, rdi - #include "cn2/cnv2_main_loop_bulldozer.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 - -ALIGN(64) -FN_PREFIX(cnv2_double_mainloop_sandybridge_asm): - sub rsp, 48 - mov rcx, rdi - mov rdx, rsi - #include "cn2/cnv2_double_main_loop_sandybridge.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 - -ALIGN(64) -FN_PREFIX(cnv2_rwz_mainloop_asm): - sub rsp, 48 - mov rcx, rdi - #include "cn2/cnv2_rwz_main_loop.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 - -ALIGN(64) -FN_PREFIX(cnv2_rwz_double_mainloop_asm): - sub rsp, 48 - mov rcx, rdi - #include "cn2/cnv2_rwz_double_main_loop.inc" - add rsp, 48 - ret 0 - mov eax, 3735929054 diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_soft_aes_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_soft_aes_template_win.inc deleted file mode 100644 index d6d393a966..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_soft_aes_template_win.inc +++ /dev/null @@ -1,279 +0,0 @@ -PUBLIC CryptonightR_soft_aes_template_part1 -PUBLIC CryptonightR_soft_aes_template_mainloop -PUBLIC CryptonightR_soft_aes_template_part2 -PUBLIC CryptonightR_soft_aes_template_part3 -PUBLIC CryptonightR_soft_aes_template_end - -ALIGN(64) -CryptonightR_soft_aes_template_part1: - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movd xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movd xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movd xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movd xmm10, QWORD PTR [r10+96] - movd xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movd xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movd xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -CryptonightR_soft_aes_template_mainloop: - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movd xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movd xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movd r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - pxor xmm6, xmm1 - pxor xmm6, xmm0 - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movd rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movd rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - movaps xmm0, xmm5 - psrldq xmm0, 8 - movd r9d, xmm0 - -CryptonightR_soft_aes_template_part2: - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov edi, edi - shl rbp, 32 - or rbp, rdi - xor r8, rbp - - mov ebx, ebx - shl rsi, 32 - or rsi, rbx - xor QWORD PTR [rsp+320], rsi - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm2 - pxor xmm6, xmm1 - paddq xmm1, xmm7 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm6, xmm0 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne CryptonightR_soft_aes_template_mainloop - -CryptonightR_soft_aes_template_part3: - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -CryptonightR_soft_aes_template_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.S b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.S deleted file mode 100644 index 5f3046cb95..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.S +++ /dev/null @@ -1,1593 +0,0 @@ -#ifdef __APPLE__ -# define ALIGN(x) .align 6 -#else -# define ALIGN(x) .align 64 -#endif -.intel_syntax noprefix -#ifdef __APPLE__ -# define FN_PREFIX(fn) _ ## fn -.text -#else -# define FN_PREFIX(fn) fn -.section .text -#endif - -#define PUBLIC .global - -PUBLIC FN_PREFIX(CryptonightR_instruction0) -PUBLIC FN_PREFIX(CryptonightR_instruction1) -PUBLIC FN_PREFIX(CryptonightR_instruction2) -PUBLIC FN_PREFIX(CryptonightR_instruction3) -PUBLIC FN_PREFIX(CryptonightR_instruction4) -PUBLIC FN_PREFIX(CryptonightR_instruction5) -PUBLIC FN_PREFIX(CryptonightR_instruction6) -PUBLIC FN_PREFIX(CryptonightR_instruction7) -PUBLIC FN_PREFIX(CryptonightR_instruction8) -PUBLIC FN_PREFIX(CryptonightR_instruction9) -PUBLIC FN_PREFIX(CryptonightR_instruction10) -PUBLIC FN_PREFIX(CryptonightR_instruction11) -PUBLIC FN_PREFIX(CryptonightR_instruction12) -PUBLIC FN_PREFIX(CryptonightR_instruction13) -PUBLIC FN_PREFIX(CryptonightR_instruction14) -PUBLIC FN_PREFIX(CryptonightR_instruction15) -PUBLIC FN_PREFIX(CryptonightR_instruction16) -PUBLIC FN_PREFIX(CryptonightR_instruction17) -PUBLIC FN_PREFIX(CryptonightR_instruction18) -PUBLIC FN_PREFIX(CryptonightR_instruction19) -PUBLIC FN_PREFIX(CryptonightR_instruction20) -PUBLIC FN_PREFIX(CryptonightR_instruction21) -PUBLIC FN_PREFIX(CryptonightR_instruction22) -PUBLIC FN_PREFIX(CryptonightR_instruction23) -PUBLIC FN_PREFIX(CryptonightR_instruction24) -PUBLIC FN_PREFIX(CryptonightR_instruction25) -PUBLIC FN_PREFIX(CryptonightR_instruction26) -PUBLIC FN_PREFIX(CryptonightR_instruction27) -PUBLIC FN_PREFIX(CryptonightR_instruction28) -PUBLIC FN_PREFIX(CryptonightR_instruction29) -PUBLIC FN_PREFIX(CryptonightR_instruction30) -PUBLIC FN_PREFIX(CryptonightR_instruction31) -PUBLIC FN_PREFIX(CryptonightR_instruction32) -PUBLIC FN_PREFIX(CryptonightR_instruction33) -PUBLIC FN_PREFIX(CryptonightR_instruction34) -PUBLIC FN_PREFIX(CryptonightR_instruction35) -PUBLIC FN_PREFIX(CryptonightR_instruction36) -PUBLIC FN_PREFIX(CryptonightR_instruction37) -PUBLIC FN_PREFIX(CryptonightR_instruction38) -PUBLIC FN_PREFIX(CryptonightR_instruction39) -PUBLIC FN_PREFIX(CryptonightR_instruction40) -PUBLIC FN_PREFIX(CryptonightR_instruction41) -PUBLIC FN_PREFIX(CryptonightR_instruction42) -PUBLIC FN_PREFIX(CryptonightR_instruction43) -PUBLIC FN_PREFIX(CryptonightR_instruction44) -PUBLIC FN_PREFIX(CryptonightR_instruction45) -PUBLIC FN_PREFIX(CryptonightR_instruction46) -PUBLIC FN_PREFIX(CryptonightR_instruction47) -PUBLIC FN_PREFIX(CryptonightR_instruction48) -PUBLIC FN_PREFIX(CryptonightR_instruction49) -PUBLIC FN_PREFIX(CryptonightR_instruction50) -PUBLIC FN_PREFIX(CryptonightR_instruction51) -PUBLIC FN_PREFIX(CryptonightR_instruction52) -PUBLIC FN_PREFIX(CryptonightR_instruction53) -PUBLIC FN_PREFIX(CryptonightR_instruction54) -PUBLIC FN_PREFIX(CryptonightR_instruction55) -PUBLIC FN_PREFIX(CryptonightR_instruction56) -PUBLIC FN_PREFIX(CryptonightR_instruction57) -PUBLIC FN_PREFIX(CryptonightR_instruction58) -PUBLIC FN_PREFIX(CryptonightR_instruction59) -PUBLIC FN_PREFIX(CryptonightR_instruction60) -PUBLIC FN_PREFIX(CryptonightR_instruction61) -PUBLIC FN_PREFIX(CryptonightR_instruction62) -PUBLIC FN_PREFIX(CryptonightR_instruction63) -PUBLIC FN_PREFIX(CryptonightR_instruction64) -PUBLIC FN_PREFIX(CryptonightR_instruction65) -PUBLIC FN_PREFIX(CryptonightR_instruction66) -PUBLIC FN_PREFIX(CryptonightR_instruction67) -PUBLIC FN_PREFIX(CryptonightR_instruction68) -PUBLIC FN_PREFIX(CryptonightR_instruction69) -PUBLIC FN_PREFIX(CryptonightR_instruction70) -PUBLIC FN_PREFIX(CryptonightR_instruction71) -PUBLIC FN_PREFIX(CryptonightR_instruction72) -PUBLIC FN_PREFIX(CryptonightR_instruction73) -PUBLIC FN_PREFIX(CryptonightR_instruction74) -PUBLIC FN_PREFIX(CryptonightR_instruction75) -PUBLIC FN_PREFIX(CryptonightR_instruction76) -PUBLIC FN_PREFIX(CryptonightR_instruction77) -PUBLIC FN_PREFIX(CryptonightR_instruction78) -PUBLIC FN_PREFIX(CryptonightR_instruction79) -PUBLIC FN_PREFIX(CryptonightR_instruction80) -PUBLIC FN_PREFIX(CryptonightR_instruction81) -PUBLIC FN_PREFIX(CryptonightR_instruction82) -PUBLIC FN_PREFIX(CryptonightR_instruction83) -PUBLIC FN_PREFIX(CryptonightR_instruction84) -PUBLIC FN_PREFIX(CryptonightR_instruction85) -PUBLIC FN_PREFIX(CryptonightR_instruction86) -PUBLIC FN_PREFIX(CryptonightR_instruction87) -PUBLIC FN_PREFIX(CryptonightR_instruction88) -PUBLIC FN_PREFIX(CryptonightR_instruction89) -PUBLIC FN_PREFIX(CryptonightR_instruction90) -PUBLIC FN_PREFIX(CryptonightR_instruction91) -PUBLIC FN_PREFIX(CryptonightR_instruction92) -PUBLIC FN_PREFIX(CryptonightR_instruction93) -PUBLIC FN_PREFIX(CryptonightR_instruction94) -PUBLIC FN_PREFIX(CryptonightR_instruction95) -PUBLIC FN_PREFIX(CryptonightR_instruction96) -PUBLIC FN_PREFIX(CryptonightR_instruction97) -PUBLIC FN_PREFIX(CryptonightR_instruction98) -PUBLIC FN_PREFIX(CryptonightR_instruction99) -PUBLIC FN_PREFIX(CryptonightR_instruction100) -PUBLIC FN_PREFIX(CryptonightR_instruction101) -PUBLIC FN_PREFIX(CryptonightR_instruction102) -PUBLIC FN_PREFIX(CryptonightR_instruction103) -PUBLIC FN_PREFIX(CryptonightR_instruction104) -PUBLIC FN_PREFIX(CryptonightR_instruction105) -PUBLIC FN_PREFIX(CryptonightR_instruction106) -PUBLIC FN_PREFIX(CryptonightR_instruction107) -PUBLIC FN_PREFIX(CryptonightR_instruction108) -PUBLIC FN_PREFIX(CryptonightR_instruction109) -PUBLIC FN_PREFIX(CryptonightR_instruction110) -PUBLIC FN_PREFIX(CryptonightR_instruction111) -PUBLIC FN_PREFIX(CryptonightR_instruction112) -PUBLIC FN_PREFIX(CryptonightR_instruction113) -PUBLIC FN_PREFIX(CryptonightR_instruction114) -PUBLIC FN_PREFIX(CryptonightR_instruction115) -PUBLIC FN_PREFIX(CryptonightR_instruction116) -PUBLIC FN_PREFIX(CryptonightR_instruction117) -PUBLIC FN_PREFIX(CryptonightR_instruction118) -PUBLIC FN_PREFIX(CryptonightR_instruction119) -PUBLIC FN_PREFIX(CryptonightR_instruction120) -PUBLIC FN_PREFIX(CryptonightR_instruction121) -PUBLIC FN_PREFIX(CryptonightR_instruction122) -PUBLIC FN_PREFIX(CryptonightR_instruction123) -PUBLIC FN_PREFIX(CryptonightR_instruction124) -PUBLIC FN_PREFIX(CryptonightR_instruction125) -PUBLIC FN_PREFIX(CryptonightR_instruction126) -PUBLIC FN_PREFIX(CryptonightR_instruction127) -PUBLIC FN_PREFIX(CryptonightR_instruction128) -PUBLIC FN_PREFIX(CryptonightR_instruction129) -PUBLIC FN_PREFIX(CryptonightR_instruction130) -PUBLIC FN_PREFIX(CryptonightR_instruction131) -PUBLIC FN_PREFIX(CryptonightR_instruction132) -PUBLIC FN_PREFIX(CryptonightR_instruction133) -PUBLIC FN_PREFIX(CryptonightR_instruction134) -PUBLIC FN_PREFIX(CryptonightR_instruction135) -PUBLIC FN_PREFIX(CryptonightR_instruction136) -PUBLIC FN_PREFIX(CryptonightR_instruction137) -PUBLIC FN_PREFIX(CryptonightR_instruction138) -PUBLIC FN_PREFIX(CryptonightR_instruction139) -PUBLIC FN_PREFIX(CryptonightR_instruction140) -PUBLIC FN_PREFIX(CryptonightR_instruction141) -PUBLIC FN_PREFIX(CryptonightR_instruction142) -PUBLIC FN_PREFIX(CryptonightR_instruction143) -PUBLIC FN_PREFIX(CryptonightR_instruction144) -PUBLIC FN_PREFIX(CryptonightR_instruction145) -PUBLIC FN_PREFIX(CryptonightR_instruction146) -PUBLIC FN_PREFIX(CryptonightR_instruction147) -PUBLIC FN_PREFIX(CryptonightR_instruction148) -PUBLIC FN_PREFIX(CryptonightR_instruction149) -PUBLIC FN_PREFIX(CryptonightR_instruction150) -PUBLIC FN_PREFIX(CryptonightR_instruction151) -PUBLIC FN_PREFIX(CryptonightR_instruction152) -PUBLIC FN_PREFIX(CryptonightR_instruction153) -PUBLIC FN_PREFIX(CryptonightR_instruction154) -PUBLIC FN_PREFIX(CryptonightR_instruction155) -PUBLIC FN_PREFIX(CryptonightR_instruction156) -PUBLIC FN_PREFIX(CryptonightR_instruction157) -PUBLIC FN_PREFIX(CryptonightR_instruction158) -PUBLIC FN_PREFIX(CryptonightR_instruction159) -PUBLIC FN_PREFIX(CryptonightR_instruction160) -PUBLIC FN_PREFIX(CryptonightR_instruction161) -PUBLIC FN_PREFIX(CryptonightR_instruction162) -PUBLIC FN_PREFIX(CryptonightR_instruction163) -PUBLIC FN_PREFIX(CryptonightR_instruction164) -PUBLIC FN_PREFIX(CryptonightR_instruction165) -PUBLIC FN_PREFIX(CryptonightR_instruction166) -PUBLIC FN_PREFIX(CryptonightR_instruction167) -PUBLIC FN_PREFIX(CryptonightR_instruction168) -PUBLIC FN_PREFIX(CryptonightR_instruction169) -PUBLIC FN_PREFIX(CryptonightR_instruction170) -PUBLIC FN_PREFIX(CryptonightR_instruction171) -PUBLIC FN_PREFIX(CryptonightR_instruction172) -PUBLIC FN_PREFIX(CryptonightR_instruction173) -PUBLIC FN_PREFIX(CryptonightR_instruction174) -PUBLIC FN_PREFIX(CryptonightR_instruction175) -PUBLIC FN_PREFIX(CryptonightR_instruction176) -PUBLIC FN_PREFIX(CryptonightR_instruction177) -PUBLIC FN_PREFIX(CryptonightR_instruction178) -PUBLIC FN_PREFIX(CryptonightR_instruction179) -PUBLIC FN_PREFIX(CryptonightR_instruction180) -PUBLIC FN_PREFIX(CryptonightR_instruction181) -PUBLIC FN_PREFIX(CryptonightR_instruction182) -PUBLIC FN_PREFIX(CryptonightR_instruction183) -PUBLIC FN_PREFIX(CryptonightR_instruction184) -PUBLIC FN_PREFIX(CryptonightR_instruction185) -PUBLIC FN_PREFIX(CryptonightR_instruction186) -PUBLIC FN_PREFIX(CryptonightR_instruction187) -PUBLIC FN_PREFIX(CryptonightR_instruction188) -PUBLIC FN_PREFIX(CryptonightR_instruction189) -PUBLIC FN_PREFIX(CryptonightR_instruction190) -PUBLIC FN_PREFIX(CryptonightR_instruction191) -PUBLIC FN_PREFIX(CryptonightR_instruction192) -PUBLIC FN_PREFIX(CryptonightR_instruction193) -PUBLIC FN_PREFIX(CryptonightR_instruction194) -PUBLIC FN_PREFIX(CryptonightR_instruction195) -PUBLIC FN_PREFIX(CryptonightR_instruction196) -PUBLIC FN_PREFIX(CryptonightR_instruction197) -PUBLIC FN_PREFIX(CryptonightR_instruction198) -PUBLIC FN_PREFIX(CryptonightR_instruction199) -PUBLIC FN_PREFIX(CryptonightR_instruction200) -PUBLIC FN_PREFIX(CryptonightR_instruction201) -PUBLIC FN_PREFIX(CryptonightR_instruction202) -PUBLIC FN_PREFIX(CryptonightR_instruction203) -PUBLIC FN_PREFIX(CryptonightR_instruction204) -PUBLIC FN_PREFIX(CryptonightR_instruction205) -PUBLIC FN_PREFIX(CryptonightR_instruction206) -PUBLIC FN_PREFIX(CryptonightR_instruction207) -PUBLIC FN_PREFIX(CryptonightR_instruction208) -PUBLIC FN_PREFIX(CryptonightR_instruction209) -PUBLIC FN_PREFIX(CryptonightR_instruction210) -PUBLIC FN_PREFIX(CryptonightR_instruction211) -PUBLIC FN_PREFIX(CryptonightR_instruction212) -PUBLIC FN_PREFIX(CryptonightR_instruction213) -PUBLIC FN_PREFIX(CryptonightR_instruction214) -PUBLIC FN_PREFIX(CryptonightR_instruction215) -PUBLIC FN_PREFIX(CryptonightR_instruction216) -PUBLIC FN_PREFIX(CryptonightR_instruction217) -PUBLIC FN_PREFIX(CryptonightR_instruction218) -PUBLIC FN_PREFIX(CryptonightR_instruction219) -PUBLIC FN_PREFIX(CryptonightR_instruction220) -PUBLIC FN_PREFIX(CryptonightR_instruction221) -PUBLIC FN_PREFIX(CryptonightR_instruction222) -PUBLIC FN_PREFIX(CryptonightR_instruction223) -PUBLIC FN_PREFIX(CryptonightR_instruction224) -PUBLIC FN_PREFIX(CryptonightR_instruction225) -PUBLIC FN_PREFIX(CryptonightR_instruction226) -PUBLIC FN_PREFIX(CryptonightR_instruction227) -PUBLIC FN_PREFIX(CryptonightR_instruction228) -PUBLIC FN_PREFIX(CryptonightR_instruction229) -PUBLIC FN_PREFIX(CryptonightR_instruction230) -PUBLIC FN_PREFIX(CryptonightR_instruction231) -PUBLIC FN_PREFIX(CryptonightR_instruction232) -PUBLIC FN_PREFIX(CryptonightR_instruction233) -PUBLIC FN_PREFIX(CryptonightR_instruction234) -PUBLIC FN_PREFIX(CryptonightR_instruction235) -PUBLIC FN_PREFIX(CryptonightR_instruction236) -PUBLIC FN_PREFIX(CryptonightR_instruction237) -PUBLIC FN_PREFIX(CryptonightR_instruction238) -PUBLIC FN_PREFIX(CryptonightR_instruction239) -PUBLIC FN_PREFIX(CryptonightR_instruction240) -PUBLIC FN_PREFIX(CryptonightR_instruction241) -PUBLIC FN_PREFIX(CryptonightR_instruction242) -PUBLIC FN_PREFIX(CryptonightR_instruction243) -PUBLIC FN_PREFIX(CryptonightR_instruction244) -PUBLIC FN_PREFIX(CryptonightR_instruction245) -PUBLIC FN_PREFIX(CryptonightR_instruction246) -PUBLIC FN_PREFIX(CryptonightR_instruction247) -PUBLIC FN_PREFIX(CryptonightR_instruction248) -PUBLIC FN_PREFIX(CryptonightR_instruction249) -PUBLIC FN_PREFIX(CryptonightR_instruction250) -PUBLIC FN_PREFIX(CryptonightR_instruction251) -PUBLIC FN_PREFIX(CryptonightR_instruction252) -PUBLIC FN_PREFIX(CryptonightR_instruction253) -PUBLIC FN_PREFIX(CryptonightR_instruction254) -PUBLIC FN_PREFIX(CryptonightR_instruction255) -PUBLIC FN_PREFIX(CryptonightR_instruction256) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov0) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov1) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov2) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov3) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov4) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov5) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov6) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov7) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov8) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov9) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov10) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov11) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov12) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov13) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov14) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov15) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov16) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov17) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov18) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov19) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov20) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov21) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov22) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov23) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov24) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov25) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov26) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov27) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov28) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov29) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov30) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov31) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov32) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov33) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov34) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov35) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov36) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov37) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov38) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov39) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov40) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov41) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov42) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov43) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov44) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov45) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov46) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov47) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov48) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov49) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov50) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov51) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov52) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov53) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov54) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov55) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov56) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov57) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov58) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov59) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov60) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov61) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov62) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov63) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov64) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov65) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov66) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov67) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov68) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov69) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov70) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov71) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov72) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov73) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov74) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov75) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov76) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov77) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov78) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov79) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov80) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov81) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov82) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov83) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov84) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov85) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov86) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov87) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov88) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov89) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov90) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov91) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov92) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov93) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov94) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov95) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov96) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov97) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov98) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov99) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov100) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov101) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov102) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov103) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov104) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov105) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov106) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov107) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov108) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov109) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov110) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov111) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov112) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov113) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov114) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov115) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov116) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov117) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov118) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov119) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov120) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov121) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov122) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov123) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov124) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov125) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov126) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov127) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov128) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov129) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov130) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov131) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov132) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov133) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov134) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov135) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov136) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov137) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov138) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov139) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov140) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov141) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov142) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov143) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov144) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov145) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov146) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov147) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov148) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov149) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov150) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov151) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov152) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov153) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov154) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov155) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov156) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov157) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov158) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov159) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov160) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov161) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov162) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov163) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov164) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov165) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov166) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov167) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov168) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov169) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov170) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov171) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov172) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov173) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov174) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov175) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov176) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov177) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov178) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov179) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov180) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov181) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov182) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov183) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov184) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov185) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov186) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov187) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov188) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov189) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov190) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov191) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov192) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov193) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov194) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov195) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov196) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov197) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov198) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov199) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov200) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov201) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov202) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov203) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov204) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov205) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov206) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov207) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov208) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov209) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov210) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov211) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov212) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov213) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov214) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov215) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov216) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov217) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov218) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov219) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov220) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov221) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov222) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov223) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov224) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov225) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov226) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov227) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov228) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov229) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov230) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov231) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov232) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov233) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov234) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov235) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov236) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov237) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov238) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov239) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov240) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov241) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov242) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov243) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov244) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov245) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov246) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov247) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov248) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov249) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov250) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov251) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov252) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov253) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov254) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov255) -PUBLIC FN_PREFIX(CryptonightR_instruction_mov256) - -#include "CryptonightWOW_template.inc" -#include "CryptonightR_template.inc" - -FN_PREFIX(CryptonightR_instruction0): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction1): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction2): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction3): - add rbx, r9 - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction4): - sub rbx, r9 -FN_PREFIX(CryptonightR_instruction5): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction6): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction7): - xor rbx, r9 -FN_PREFIX(CryptonightR_instruction8): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction9): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction10): - imul rsi, rbx -FN_PREFIX(CryptonightR_instruction11): - add rsi, rbx - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction12): - sub rsi, rbx -FN_PREFIX(CryptonightR_instruction13): - ror esi, cl -FN_PREFIX(CryptonightR_instruction14): - rol esi, cl -FN_PREFIX(CryptonightR_instruction15): - xor rsi, rbx -FN_PREFIX(CryptonightR_instruction16): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction17): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction18): - imul rdi, rbx -FN_PREFIX(CryptonightR_instruction19): - add rdi, rbx - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction20): - sub rdi, rbx -FN_PREFIX(CryptonightR_instruction21): - ror edi, cl -FN_PREFIX(CryptonightR_instruction22): - rol edi, cl -FN_PREFIX(CryptonightR_instruction23): - xor rdi, rbx -FN_PREFIX(CryptonightR_instruction24): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction25): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction26): - imul rbp, rbx -FN_PREFIX(CryptonightR_instruction27): - add rbp, rbx - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction28): - sub rbp, rbx -FN_PREFIX(CryptonightR_instruction29): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction30): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction31): - xor rbp, rbx -FN_PREFIX(CryptonightR_instruction32): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction33): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction34): - imul rbx, rsi -FN_PREFIX(CryptonightR_instruction35): - add rbx, rsi - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction36): - sub rbx, rsi -FN_PREFIX(CryptonightR_instruction37): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction38): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction39): - xor rbx, rsi -FN_PREFIX(CryptonightR_instruction40): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction41): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction42): - imul rsi, rsi -FN_PREFIX(CryptonightR_instruction43): - add rsi, r9 - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction44): - sub rsi, r9 -FN_PREFIX(CryptonightR_instruction45): - ror esi, cl -FN_PREFIX(CryptonightR_instruction46): - rol esi, cl -FN_PREFIX(CryptonightR_instruction47): - xor rsi, r9 -FN_PREFIX(CryptonightR_instruction48): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction49): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction50): - imul rdi, rsi -FN_PREFIX(CryptonightR_instruction51): - add rdi, rsi - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction52): - sub rdi, rsi -FN_PREFIX(CryptonightR_instruction53): - ror edi, cl -FN_PREFIX(CryptonightR_instruction54): - rol edi, cl -FN_PREFIX(CryptonightR_instruction55): - xor rdi, rsi -FN_PREFIX(CryptonightR_instruction56): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction57): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction58): - imul rbp, rsi -FN_PREFIX(CryptonightR_instruction59): - add rbp, rsi - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction60): - sub rbp, rsi -FN_PREFIX(CryptonightR_instruction61): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction62): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction63): - xor rbp, rsi -FN_PREFIX(CryptonightR_instruction64): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction65): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction66): - imul rbx, rdi -FN_PREFIX(CryptonightR_instruction67): - add rbx, rdi - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction68): - sub rbx, rdi -FN_PREFIX(CryptonightR_instruction69): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction70): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction71): - xor rbx, rdi -FN_PREFIX(CryptonightR_instruction72): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction73): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction74): - imul rsi, rdi -FN_PREFIX(CryptonightR_instruction75): - add rsi, rdi - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction76): - sub rsi, rdi -FN_PREFIX(CryptonightR_instruction77): - ror esi, cl -FN_PREFIX(CryptonightR_instruction78): - rol esi, cl -FN_PREFIX(CryptonightR_instruction79): - xor rsi, rdi -FN_PREFIX(CryptonightR_instruction80): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction81): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction82): - imul rdi, rdi -FN_PREFIX(CryptonightR_instruction83): - add rdi, r9 - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction84): - sub rdi, r9 -FN_PREFIX(CryptonightR_instruction85): - ror edi, cl -FN_PREFIX(CryptonightR_instruction86): - rol edi, cl -FN_PREFIX(CryptonightR_instruction87): - xor rdi, r9 -FN_PREFIX(CryptonightR_instruction88): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction89): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction90): - imul rbp, rdi -FN_PREFIX(CryptonightR_instruction91): - add rbp, rdi - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction92): - sub rbp, rdi -FN_PREFIX(CryptonightR_instruction93): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction94): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction95): - xor rbp, rdi -FN_PREFIX(CryptonightR_instruction96): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction97): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction98): - imul rbx, rbp -FN_PREFIX(CryptonightR_instruction99): - add rbx, rbp - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction100): - sub rbx, rbp -FN_PREFIX(CryptonightR_instruction101): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction102): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction103): - xor rbx, rbp -FN_PREFIX(CryptonightR_instruction104): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction105): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction106): - imul rsi, rbp -FN_PREFIX(CryptonightR_instruction107): - add rsi, rbp - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction108): - sub rsi, rbp -FN_PREFIX(CryptonightR_instruction109): - ror esi, cl -FN_PREFIX(CryptonightR_instruction110): - rol esi, cl -FN_PREFIX(CryptonightR_instruction111): - xor rsi, rbp -FN_PREFIX(CryptonightR_instruction112): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction113): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction114): - imul rdi, rbp -FN_PREFIX(CryptonightR_instruction115): - add rdi, rbp - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction116): - sub rdi, rbp -FN_PREFIX(CryptonightR_instruction117): - ror edi, cl -FN_PREFIX(CryptonightR_instruction118): - rol edi, cl -FN_PREFIX(CryptonightR_instruction119): - xor rdi, rbp -FN_PREFIX(CryptonightR_instruction120): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction121): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction122): - imul rbp, rbp -FN_PREFIX(CryptonightR_instruction123): - add rbp, r9 - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction124): - sub rbp, r9 -FN_PREFIX(CryptonightR_instruction125): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction126): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction127): - xor rbp, r9 -FN_PREFIX(CryptonightR_instruction128): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction129): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction130): - imul rbx, rsp -FN_PREFIX(CryptonightR_instruction131): - add rbx, rsp - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction132): - sub rbx, rsp -FN_PREFIX(CryptonightR_instruction133): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction134): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction135): - xor rbx, rsp -FN_PREFIX(CryptonightR_instruction136): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction137): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction138): - imul rsi, rsp -FN_PREFIX(CryptonightR_instruction139): - add rsi, rsp - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction140): - sub rsi, rsp -FN_PREFIX(CryptonightR_instruction141): - ror esi, cl -FN_PREFIX(CryptonightR_instruction142): - rol esi, cl -FN_PREFIX(CryptonightR_instruction143): - xor rsi, rsp -FN_PREFIX(CryptonightR_instruction144): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction145): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction146): - imul rdi, rsp -FN_PREFIX(CryptonightR_instruction147): - add rdi, rsp - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction148): - sub rdi, rsp -FN_PREFIX(CryptonightR_instruction149): - ror edi, cl -FN_PREFIX(CryptonightR_instruction150): - rol edi, cl -FN_PREFIX(CryptonightR_instruction151): - xor rdi, rsp -FN_PREFIX(CryptonightR_instruction152): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction153): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction154): - imul rbp, rsp -FN_PREFIX(CryptonightR_instruction155): - add rbp, rsp - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction156): - sub rbp, rsp -FN_PREFIX(CryptonightR_instruction157): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction158): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction159): - xor rbp, rsp -FN_PREFIX(CryptonightR_instruction160): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction161): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction162): - imul rbx, r15 -FN_PREFIX(CryptonightR_instruction163): - add rbx, r15 - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction164): - sub rbx, r15 -FN_PREFIX(CryptonightR_instruction165): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction166): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction167): - xor rbx, r15 -FN_PREFIX(CryptonightR_instruction168): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction169): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction170): - imul rsi, r15 -FN_PREFIX(CryptonightR_instruction171): - add rsi, r15 - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction172): - sub rsi, r15 -FN_PREFIX(CryptonightR_instruction173): - ror esi, cl -FN_PREFIX(CryptonightR_instruction174): - rol esi, cl -FN_PREFIX(CryptonightR_instruction175): - xor rsi, r15 -FN_PREFIX(CryptonightR_instruction176): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction177): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction178): - imul rdi, r15 -FN_PREFIX(CryptonightR_instruction179): - add rdi, r15 - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction180): - sub rdi, r15 -FN_PREFIX(CryptonightR_instruction181): - ror edi, cl -FN_PREFIX(CryptonightR_instruction182): - rol edi, cl -FN_PREFIX(CryptonightR_instruction183): - xor rdi, r15 -FN_PREFIX(CryptonightR_instruction184): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction185): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction186): - imul rbp, r15 -FN_PREFIX(CryptonightR_instruction187): - add rbp, r15 - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction188): - sub rbp, r15 -FN_PREFIX(CryptonightR_instruction189): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction190): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction191): - xor rbp, r15 -FN_PREFIX(CryptonightR_instruction192): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction193): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction194): - imul rbx, rax -FN_PREFIX(CryptonightR_instruction195): - add rbx, rax - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction196): - sub rbx, rax -FN_PREFIX(CryptonightR_instruction197): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction198): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction199): - xor rbx, rax -FN_PREFIX(CryptonightR_instruction200): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction201): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction202): - imul rsi, rax -FN_PREFIX(CryptonightR_instruction203): - add rsi, rax - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction204): - sub rsi, rax -FN_PREFIX(CryptonightR_instruction205): - ror esi, cl -FN_PREFIX(CryptonightR_instruction206): - rol esi, cl -FN_PREFIX(CryptonightR_instruction207): - xor rsi, rax -FN_PREFIX(CryptonightR_instruction208): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction209): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction210): - imul rdi, rax -FN_PREFIX(CryptonightR_instruction211): - add rdi, rax - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction212): - sub rdi, rax -FN_PREFIX(CryptonightR_instruction213): - ror edi, cl -FN_PREFIX(CryptonightR_instruction214): - rol edi, cl -FN_PREFIX(CryptonightR_instruction215): - xor rdi, rax -FN_PREFIX(CryptonightR_instruction216): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction217): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction218): - imul rbp, rax -FN_PREFIX(CryptonightR_instruction219): - add rbp, rax - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction220): - sub rbp, rax -FN_PREFIX(CryptonightR_instruction221): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction222): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction223): - xor rbp, rax -FN_PREFIX(CryptonightR_instruction224): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction225): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction226): - imul rbx, rdx -FN_PREFIX(CryptonightR_instruction227): - add rbx, rdx - add rbx, 2147483647 -FN_PREFIX(CryptonightR_instruction228): - sub rbx, rdx -FN_PREFIX(CryptonightR_instruction229): - ror ebx, cl -FN_PREFIX(CryptonightR_instruction230): - rol ebx, cl -FN_PREFIX(CryptonightR_instruction231): - xor rbx, rdx -FN_PREFIX(CryptonightR_instruction232): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction233): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction234): - imul rsi, rdx -FN_PREFIX(CryptonightR_instruction235): - add rsi, rdx - add rsi, 2147483647 -FN_PREFIX(CryptonightR_instruction236): - sub rsi, rdx -FN_PREFIX(CryptonightR_instruction237): - ror esi, cl -FN_PREFIX(CryptonightR_instruction238): - rol esi, cl -FN_PREFIX(CryptonightR_instruction239): - xor rsi, rdx -FN_PREFIX(CryptonightR_instruction240): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction241): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction242): - imul rdi, rdx -FN_PREFIX(CryptonightR_instruction243): - add rdi, rdx - add rdi, 2147483647 -FN_PREFIX(CryptonightR_instruction244): - sub rdi, rdx -FN_PREFIX(CryptonightR_instruction245): - ror edi, cl -FN_PREFIX(CryptonightR_instruction246): - rol edi, cl -FN_PREFIX(CryptonightR_instruction247): - xor rdi, rdx -FN_PREFIX(CryptonightR_instruction248): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction249): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction250): - imul rbp, rdx -FN_PREFIX(CryptonightR_instruction251): - add rbp, rdx - add rbp, 2147483647 -FN_PREFIX(CryptonightR_instruction252): - sub rbp, rdx -FN_PREFIX(CryptonightR_instruction253): - ror ebp, cl -FN_PREFIX(CryptonightR_instruction254): - rol ebp, cl -FN_PREFIX(CryptonightR_instruction255): - xor rbp, rdx -FN_PREFIX(CryptonightR_instruction256): - imul rbx, rbx -FN_PREFIX(CryptonightR_instruction_mov0): - -FN_PREFIX(CryptonightR_instruction_mov1): - -FN_PREFIX(CryptonightR_instruction_mov2): - -FN_PREFIX(CryptonightR_instruction_mov3): - -FN_PREFIX(CryptonightR_instruction_mov4): - -FN_PREFIX(CryptonightR_instruction_mov5): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov6): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov7): - -FN_PREFIX(CryptonightR_instruction_mov8): - -FN_PREFIX(CryptonightR_instruction_mov9): - -FN_PREFIX(CryptonightR_instruction_mov10): - -FN_PREFIX(CryptonightR_instruction_mov11): - -FN_PREFIX(CryptonightR_instruction_mov12): - -FN_PREFIX(CryptonightR_instruction_mov13): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov14): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov15): - -FN_PREFIX(CryptonightR_instruction_mov16): - -FN_PREFIX(CryptonightR_instruction_mov17): - -FN_PREFIX(CryptonightR_instruction_mov18): - -FN_PREFIX(CryptonightR_instruction_mov19): - -FN_PREFIX(CryptonightR_instruction_mov20): - -FN_PREFIX(CryptonightR_instruction_mov21): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov22): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov23): - -FN_PREFIX(CryptonightR_instruction_mov24): - -FN_PREFIX(CryptonightR_instruction_mov25): - -FN_PREFIX(CryptonightR_instruction_mov26): - -FN_PREFIX(CryptonightR_instruction_mov27): - -FN_PREFIX(CryptonightR_instruction_mov28): - -FN_PREFIX(CryptonightR_instruction_mov29): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov30): - mov rcx, rbx -FN_PREFIX(CryptonightR_instruction_mov31): - -FN_PREFIX(CryptonightR_instruction_mov32): - -FN_PREFIX(CryptonightR_instruction_mov33): - -FN_PREFIX(CryptonightR_instruction_mov34): - -FN_PREFIX(CryptonightR_instruction_mov35): - -FN_PREFIX(CryptonightR_instruction_mov36): - -FN_PREFIX(CryptonightR_instruction_mov37): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov38): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov39): - -FN_PREFIX(CryptonightR_instruction_mov40): - -FN_PREFIX(CryptonightR_instruction_mov41): - -FN_PREFIX(CryptonightR_instruction_mov42): - -FN_PREFIX(CryptonightR_instruction_mov43): - -FN_PREFIX(CryptonightR_instruction_mov44): - -FN_PREFIX(CryptonightR_instruction_mov45): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov46): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov47): - -FN_PREFIX(CryptonightR_instruction_mov48): - -FN_PREFIX(CryptonightR_instruction_mov49): - -FN_PREFIX(CryptonightR_instruction_mov50): - -FN_PREFIX(CryptonightR_instruction_mov51): - -FN_PREFIX(CryptonightR_instruction_mov52): - -FN_PREFIX(CryptonightR_instruction_mov53): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov54): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov55): - -FN_PREFIX(CryptonightR_instruction_mov56): - -FN_PREFIX(CryptonightR_instruction_mov57): - -FN_PREFIX(CryptonightR_instruction_mov58): - -FN_PREFIX(CryptonightR_instruction_mov59): - -FN_PREFIX(CryptonightR_instruction_mov60): - -FN_PREFIX(CryptonightR_instruction_mov61): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov62): - mov rcx, rsi -FN_PREFIX(CryptonightR_instruction_mov63): - -FN_PREFIX(CryptonightR_instruction_mov64): - -FN_PREFIX(CryptonightR_instruction_mov65): - -FN_PREFIX(CryptonightR_instruction_mov66): - -FN_PREFIX(CryptonightR_instruction_mov67): - -FN_PREFIX(CryptonightR_instruction_mov68): - -FN_PREFIX(CryptonightR_instruction_mov69): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov70): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov71): - -FN_PREFIX(CryptonightR_instruction_mov72): - -FN_PREFIX(CryptonightR_instruction_mov73): - -FN_PREFIX(CryptonightR_instruction_mov74): - -FN_PREFIX(CryptonightR_instruction_mov75): - -FN_PREFIX(CryptonightR_instruction_mov76): - -FN_PREFIX(CryptonightR_instruction_mov77): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov78): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov79): - -FN_PREFIX(CryptonightR_instruction_mov80): - -FN_PREFIX(CryptonightR_instruction_mov81): - -FN_PREFIX(CryptonightR_instruction_mov82): - -FN_PREFIX(CryptonightR_instruction_mov83): - -FN_PREFIX(CryptonightR_instruction_mov84): - -FN_PREFIX(CryptonightR_instruction_mov85): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov86): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov87): - -FN_PREFIX(CryptonightR_instruction_mov88): - -FN_PREFIX(CryptonightR_instruction_mov89): - -FN_PREFIX(CryptonightR_instruction_mov90): - -FN_PREFIX(CryptonightR_instruction_mov91): - -FN_PREFIX(CryptonightR_instruction_mov92): - -FN_PREFIX(CryptonightR_instruction_mov93): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov94): - mov rcx, rdi -FN_PREFIX(CryptonightR_instruction_mov95): - -FN_PREFIX(CryptonightR_instruction_mov96): - -FN_PREFIX(CryptonightR_instruction_mov97): - -FN_PREFIX(CryptonightR_instruction_mov98): - -FN_PREFIX(CryptonightR_instruction_mov99): - -FN_PREFIX(CryptonightR_instruction_mov100): - -FN_PREFIX(CryptonightR_instruction_mov101): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov102): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov103): - -FN_PREFIX(CryptonightR_instruction_mov104): - -FN_PREFIX(CryptonightR_instruction_mov105): - -FN_PREFIX(CryptonightR_instruction_mov106): - -FN_PREFIX(CryptonightR_instruction_mov107): - -FN_PREFIX(CryptonightR_instruction_mov108): - -FN_PREFIX(CryptonightR_instruction_mov109): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov110): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov111): - -FN_PREFIX(CryptonightR_instruction_mov112): - -FN_PREFIX(CryptonightR_instruction_mov113): - -FN_PREFIX(CryptonightR_instruction_mov114): - -FN_PREFIX(CryptonightR_instruction_mov115): - -FN_PREFIX(CryptonightR_instruction_mov116): - -FN_PREFIX(CryptonightR_instruction_mov117): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov118): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov119): - -FN_PREFIX(CryptonightR_instruction_mov120): - -FN_PREFIX(CryptonightR_instruction_mov121): - -FN_PREFIX(CryptonightR_instruction_mov122): - -FN_PREFIX(CryptonightR_instruction_mov123): - -FN_PREFIX(CryptonightR_instruction_mov124): - -FN_PREFIX(CryptonightR_instruction_mov125): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov126): - mov rcx, rbp -FN_PREFIX(CryptonightR_instruction_mov127): - -FN_PREFIX(CryptonightR_instruction_mov128): - -FN_PREFIX(CryptonightR_instruction_mov129): - -FN_PREFIX(CryptonightR_instruction_mov130): - -FN_PREFIX(CryptonightR_instruction_mov131): - -FN_PREFIX(CryptonightR_instruction_mov132): - -FN_PREFIX(CryptonightR_instruction_mov133): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov134): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov135): - -FN_PREFIX(CryptonightR_instruction_mov136): - -FN_PREFIX(CryptonightR_instruction_mov137): - -FN_PREFIX(CryptonightR_instruction_mov138): - -FN_PREFIX(CryptonightR_instruction_mov139): - -FN_PREFIX(CryptonightR_instruction_mov140): - -FN_PREFIX(CryptonightR_instruction_mov141): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov142): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov143): - -FN_PREFIX(CryptonightR_instruction_mov144): - -FN_PREFIX(CryptonightR_instruction_mov145): - -FN_PREFIX(CryptonightR_instruction_mov146): - -FN_PREFIX(CryptonightR_instruction_mov147): - -FN_PREFIX(CryptonightR_instruction_mov148): - -FN_PREFIX(CryptonightR_instruction_mov149): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov150): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov151): - -FN_PREFIX(CryptonightR_instruction_mov152): - -FN_PREFIX(CryptonightR_instruction_mov153): - -FN_PREFIX(CryptonightR_instruction_mov154): - -FN_PREFIX(CryptonightR_instruction_mov155): - -FN_PREFIX(CryptonightR_instruction_mov156): - -FN_PREFIX(CryptonightR_instruction_mov157): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov158): - mov rcx, rsp -FN_PREFIX(CryptonightR_instruction_mov159): - -FN_PREFIX(CryptonightR_instruction_mov160): - -FN_PREFIX(CryptonightR_instruction_mov161): - -FN_PREFIX(CryptonightR_instruction_mov162): - -FN_PREFIX(CryptonightR_instruction_mov163): - -FN_PREFIX(CryptonightR_instruction_mov164): - -FN_PREFIX(CryptonightR_instruction_mov165): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov166): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov167): - -FN_PREFIX(CryptonightR_instruction_mov168): - -FN_PREFIX(CryptonightR_instruction_mov169): - -FN_PREFIX(CryptonightR_instruction_mov170): - -FN_PREFIX(CryptonightR_instruction_mov171): - -FN_PREFIX(CryptonightR_instruction_mov172): - -FN_PREFIX(CryptonightR_instruction_mov173): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov174): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov175): - -FN_PREFIX(CryptonightR_instruction_mov176): - -FN_PREFIX(CryptonightR_instruction_mov177): - -FN_PREFIX(CryptonightR_instruction_mov178): - -FN_PREFIX(CryptonightR_instruction_mov179): - -FN_PREFIX(CryptonightR_instruction_mov180): - -FN_PREFIX(CryptonightR_instruction_mov181): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov182): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov183): - -FN_PREFIX(CryptonightR_instruction_mov184): - -FN_PREFIX(CryptonightR_instruction_mov185): - -FN_PREFIX(CryptonightR_instruction_mov186): - -FN_PREFIX(CryptonightR_instruction_mov187): - -FN_PREFIX(CryptonightR_instruction_mov188): - -FN_PREFIX(CryptonightR_instruction_mov189): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov190): - mov rcx, r15 -FN_PREFIX(CryptonightR_instruction_mov191): - -FN_PREFIX(CryptonightR_instruction_mov192): - -FN_PREFIX(CryptonightR_instruction_mov193): - -FN_PREFIX(CryptonightR_instruction_mov194): - -FN_PREFIX(CryptonightR_instruction_mov195): - -FN_PREFIX(CryptonightR_instruction_mov196): - -FN_PREFIX(CryptonightR_instruction_mov197): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov198): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov199): - -FN_PREFIX(CryptonightR_instruction_mov200): - -FN_PREFIX(CryptonightR_instruction_mov201): - -FN_PREFIX(CryptonightR_instruction_mov202): - -FN_PREFIX(CryptonightR_instruction_mov203): - -FN_PREFIX(CryptonightR_instruction_mov204): - -FN_PREFIX(CryptonightR_instruction_mov205): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov206): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov207): - -FN_PREFIX(CryptonightR_instruction_mov208): - -FN_PREFIX(CryptonightR_instruction_mov209): - -FN_PREFIX(CryptonightR_instruction_mov210): - -FN_PREFIX(CryptonightR_instruction_mov211): - -FN_PREFIX(CryptonightR_instruction_mov212): - -FN_PREFIX(CryptonightR_instruction_mov213): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov214): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov215): - -FN_PREFIX(CryptonightR_instruction_mov216): - -FN_PREFIX(CryptonightR_instruction_mov217): - -FN_PREFIX(CryptonightR_instruction_mov218): - -FN_PREFIX(CryptonightR_instruction_mov219): - -FN_PREFIX(CryptonightR_instruction_mov220): - -FN_PREFIX(CryptonightR_instruction_mov221): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov222): - mov rcx, rax -FN_PREFIX(CryptonightR_instruction_mov223): - -FN_PREFIX(CryptonightR_instruction_mov224): - -FN_PREFIX(CryptonightR_instruction_mov225): - -FN_PREFIX(CryptonightR_instruction_mov226): - -FN_PREFIX(CryptonightR_instruction_mov227): - -FN_PREFIX(CryptonightR_instruction_mov228): - -FN_PREFIX(CryptonightR_instruction_mov229): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov230): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov231): - -FN_PREFIX(CryptonightR_instruction_mov232): - -FN_PREFIX(CryptonightR_instruction_mov233): - -FN_PREFIX(CryptonightR_instruction_mov234): - -FN_PREFIX(CryptonightR_instruction_mov235): - -FN_PREFIX(CryptonightR_instruction_mov236): - -FN_PREFIX(CryptonightR_instruction_mov237): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov238): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov239): - -FN_PREFIX(CryptonightR_instruction_mov240): - -FN_PREFIX(CryptonightR_instruction_mov241): - -FN_PREFIX(CryptonightR_instruction_mov242): - -FN_PREFIX(CryptonightR_instruction_mov243): - -FN_PREFIX(CryptonightR_instruction_mov244): - -FN_PREFIX(CryptonightR_instruction_mov245): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov246): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov247): - -FN_PREFIX(CryptonightR_instruction_mov248): - -FN_PREFIX(CryptonightR_instruction_mov249): - -FN_PREFIX(CryptonightR_instruction_mov250): - -FN_PREFIX(CryptonightR_instruction_mov251): - -FN_PREFIX(CryptonightR_instruction_mov252): - -FN_PREFIX(CryptonightR_instruction_mov253): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov254): - mov rcx, rdx -FN_PREFIX(CryptonightR_instruction_mov255): - -FN_PREFIX(CryptonightR_instruction_mov256): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.asm b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.asm deleted file mode 100644 index 250eca3d08..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.asm +++ /dev/null @@ -1,1585 +0,0 @@ -; Auto-generated file, do not edit - -_TEXT_CN_TEMPLATE SEGMENT PAGE READ EXECUTE -PUBLIC CryptonightR_instruction0 -PUBLIC CryptonightR_instruction1 -PUBLIC CryptonightR_instruction2 -PUBLIC CryptonightR_instruction3 -PUBLIC CryptonightR_instruction4 -PUBLIC CryptonightR_instruction5 -PUBLIC CryptonightR_instruction6 -PUBLIC CryptonightR_instruction7 -PUBLIC CryptonightR_instruction8 -PUBLIC CryptonightR_instruction9 -PUBLIC CryptonightR_instruction10 -PUBLIC CryptonightR_instruction11 -PUBLIC CryptonightR_instruction12 -PUBLIC CryptonightR_instruction13 -PUBLIC CryptonightR_instruction14 -PUBLIC CryptonightR_instruction15 -PUBLIC CryptonightR_instruction16 -PUBLIC CryptonightR_instruction17 -PUBLIC CryptonightR_instruction18 -PUBLIC CryptonightR_instruction19 -PUBLIC CryptonightR_instruction20 -PUBLIC CryptonightR_instruction21 -PUBLIC CryptonightR_instruction22 -PUBLIC CryptonightR_instruction23 -PUBLIC CryptonightR_instruction24 -PUBLIC CryptonightR_instruction25 -PUBLIC CryptonightR_instruction26 -PUBLIC CryptonightR_instruction27 -PUBLIC CryptonightR_instruction28 -PUBLIC CryptonightR_instruction29 -PUBLIC CryptonightR_instruction30 -PUBLIC CryptonightR_instruction31 -PUBLIC CryptonightR_instruction32 -PUBLIC CryptonightR_instruction33 -PUBLIC CryptonightR_instruction34 -PUBLIC CryptonightR_instruction35 -PUBLIC CryptonightR_instruction36 -PUBLIC CryptonightR_instruction37 -PUBLIC CryptonightR_instruction38 -PUBLIC CryptonightR_instruction39 -PUBLIC CryptonightR_instruction40 -PUBLIC CryptonightR_instruction41 -PUBLIC CryptonightR_instruction42 -PUBLIC CryptonightR_instruction43 -PUBLIC CryptonightR_instruction44 -PUBLIC CryptonightR_instruction45 -PUBLIC CryptonightR_instruction46 -PUBLIC CryptonightR_instruction47 -PUBLIC CryptonightR_instruction48 -PUBLIC CryptonightR_instruction49 -PUBLIC CryptonightR_instruction50 -PUBLIC CryptonightR_instruction51 -PUBLIC CryptonightR_instruction52 -PUBLIC CryptonightR_instruction53 -PUBLIC CryptonightR_instruction54 -PUBLIC CryptonightR_instruction55 -PUBLIC CryptonightR_instruction56 -PUBLIC CryptonightR_instruction57 -PUBLIC CryptonightR_instruction58 -PUBLIC CryptonightR_instruction59 -PUBLIC CryptonightR_instruction60 -PUBLIC CryptonightR_instruction61 -PUBLIC CryptonightR_instruction62 -PUBLIC CryptonightR_instruction63 -PUBLIC CryptonightR_instruction64 -PUBLIC CryptonightR_instruction65 -PUBLIC CryptonightR_instruction66 -PUBLIC CryptonightR_instruction67 -PUBLIC CryptonightR_instruction68 -PUBLIC CryptonightR_instruction69 -PUBLIC CryptonightR_instruction70 -PUBLIC CryptonightR_instruction71 -PUBLIC CryptonightR_instruction72 -PUBLIC CryptonightR_instruction73 -PUBLIC CryptonightR_instruction74 -PUBLIC CryptonightR_instruction75 -PUBLIC CryptonightR_instruction76 -PUBLIC CryptonightR_instruction77 -PUBLIC CryptonightR_instruction78 -PUBLIC CryptonightR_instruction79 -PUBLIC CryptonightR_instruction80 -PUBLIC CryptonightR_instruction81 -PUBLIC CryptonightR_instruction82 -PUBLIC CryptonightR_instruction83 -PUBLIC CryptonightR_instruction84 -PUBLIC CryptonightR_instruction85 -PUBLIC CryptonightR_instruction86 -PUBLIC CryptonightR_instruction87 -PUBLIC CryptonightR_instruction88 -PUBLIC CryptonightR_instruction89 -PUBLIC CryptonightR_instruction90 -PUBLIC CryptonightR_instruction91 -PUBLIC CryptonightR_instruction92 -PUBLIC CryptonightR_instruction93 -PUBLIC CryptonightR_instruction94 -PUBLIC CryptonightR_instruction95 -PUBLIC CryptonightR_instruction96 -PUBLIC CryptonightR_instruction97 -PUBLIC CryptonightR_instruction98 -PUBLIC CryptonightR_instruction99 -PUBLIC CryptonightR_instruction100 -PUBLIC CryptonightR_instruction101 -PUBLIC CryptonightR_instruction102 -PUBLIC CryptonightR_instruction103 -PUBLIC CryptonightR_instruction104 -PUBLIC CryptonightR_instruction105 -PUBLIC CryptonightR_instruction106 -PUBLIC CryptonightR_instruction107 -PUBLIC CryptonightR_instruction108 -PUBLIC CryptonightR_instruction109 -PUBLIC CryptonightR_instruction110 -PUBLIC CryptonightR_instruction111 -PUBLIC CryptonightR_instruction112 -PUBLIC CryptonightR_instruction113 -PUBLIC CryptonightR_instruction114 -PUBLIC CryptonightR_instruction115 -PUBLIC CryptonightR_instruction116 -PUBLIC CryptonightR_instruction117 -PUBLIC CryptonightR_instruction118 -PUBLIC CryptonightR_instruction119 -PUBLIC CryptonightR_instruction120 -PUBLIC CryptonightR_instruction121 -PUBLIC CryptonightR_instruction122 -PUBLIC CryptonightR_instruction123 -PUBLIC CryptonightR_instruction124 -PUBLIC CryptonightR_instruction125 -PUBLIC CryptonightR_instruction126 -PUBLIC CryptonightR_instruction127 -PUBLIC CryptonightR_instruction128 -PUBLIC CryptonightR_instruction129 -PUBLIC CryptonightR_instruction130 -PUBLIC CryptonightR_instruction131 -PUBLIC CryptonightR_instruction132 -PUBLIC CryptonightR_instruction133 -PUBLIC CryptonightR_instruction134 -PUBLIC CryptonightR_instruction135 -PUBLIC CryptonightR_instruction136 -PUBLIC CryptonightR_instruction137 -PUBLIC CryptonightR_instruction138 -PUBLIC CryptonightR_instruction139 -PUBLIC CryptonightR_instruction140 -PUBLIC CryptonightR_instruction141 -PUBLIC CryptonightR_instruction142 -PUBLIC CryptonightR_instruction143 -PUBLIC CryptonightR_instruction144 -PUBLIC CryptonightR_instruction145 -PUBLIC CryptonightR_instruction146 -PUBLIC CryptonightR_instruction147 -PUBLIC CryptonightR_instruction148 -PUBLIC CryptonightR_instruction149 -PUBLIC CryptonightR_instruction150 -PUBLIC CryptonightR_instruction151 -PUBLIC CryptonightR_instruction152 -PUBLIC CryptonightR_instruction153 -PUBLIC CryptonightR_instruction154 -PUBLIC CryptonightR_instruction155 -PUBLIC CryptonightR_instruction156 -PUBLIC CryptonightR_instruction157 -PUBLIC CryptonightR_instruction158 -PUBLIC CryptonightR_instruction159 -PUBLIC CryptonightR_instruction160 -PUBLIC CryptonightR_instruction161 -PUBLIC CryptonightR_instruction162 -PUBLIC CryptonightR_instruction163 -PUBLIC CryptonightR_instruction164 -PUBLIC CryptonightR_instruction165 -PUBLIC CryptonightR_instruction166 -PUBLIC CryptonightR_instruction167 -PUBLIC CryptonightR_instruction168 -PUBLIC CryptonightR_instruction169 -PUBLIC CryptonightR_instruction170 -PUBLIC CryptonightR_instruction171 -PUBLIC CryptonightR_instruction172 -PUBLIC CryptonightR_instruction173 -PUBLIC CryptonightR_instruction174 -PUBLIC CryptonightR_instruction175 -PUBLIC CryptonightR_instruction176 -PUBLIC CryptonightR_instruction177 -PUBLIC CryptonightR_instruction178 -PUBLIC CryptonightR_instruction179 -PUBLIC CryptonightR_instruction180 -PUBLIC CryptonightR_instruction181 -PUBLIC CryptonightR_instruction182 -PUBLIC CryptonightR_instruction183 -PUBLIC CryptonightR_instruction184 -PUBLIC CryptonightR_instruction185 -PUBLIC CryptonightR_instruction186 -PUBLIC CryptonightR_instruction187 -PUBLIC CryptonightR_instruction188 -PUBLIC CryptonightR_instruction189 -PUBLIC CryptonightR_instruction190 -PUBLIC CryptonightR_instruction191 -PUBLIC CryptonightR_instruction192 -PUBLIC CryptonightR_instruction193 -PUBLIC CryptonightR_instruction194 -PUBLIC CryptonightR_instruction195 -PUBLIC CryptonightR_instruction196 -PUBLIC CryptonightR_instruction197 -PUBLIC CryptonightR_instruction198 -PUBLIC CryptonightR_instruction199 -PUBLIC CryptonightR_instruction200 -PUBLIC CryptonightR_instruction201 -PUBLIC CryptonightR_instruction202 -PUBLIC CryptonightR_instruction203 -PUBLIC CryptonightR_instruction204 -PUBLIC CryptonightR_instruction205 -PUBLIC CryptonightR_instruction206 -PUBLIC CryptonightR_instruction207 -PUBLIC CryptonightR_instruction208 -PUBLIC CryptonightR_instruction209 -PUBLIC CryptonightR_instruction210 -PUBLIC CryptonightR_instruction211 -PUBLIC CryptonightR_instruction212 -PUBLIC CryptonightR_instruction213 -PUBLIC CryptonightR_instruction214 -PUBLIC CryptonightR_instruction215 -PUBLIC CryptonightR_instruction216 -PUBLIC CryptonightR_instruction217 -PUBLIC CryptonightR_instruction218 -PUBLIC CryptonightR_instruction219 -PUBLIC CryptonightR_instruction220 -PUBLIC CryptonightR_instruction221 -PUBLIC CryptonightR_instruction222 -PUBLIC CryptonightR_instruction223 -PUBLIC CryptonightR_instruction224 -PUBLIC CryptonightR_instruction225 -PUBLIC CryptonightR_instruction226 -PUBLIC CryptonightR_instruction227 -PUBLIC CryptonightR_instruction228 -PUBLIC CryptonightR_instruction229 -PUBLIC CryptonightR_instruction230 -PUBLIC CryptonightR_instruction231 -PUBLIC CryptonightR_instruction232 -PUBLIC CryptonightR_instruction233 -PUBLIC CryptonightR_instruction234 -PUBLIC CryptonightR_instruction235 -PUBLIC CryptonightR_instruction236 -PUBLIC CryptonightR_instruction237 -PUBLIC CryptonightR_instruction238 -PUBLIC CryptonightR_instruction239 -PUBLIC CryptonightR_instruction240 -PUBLIC CryptonightR_instruction241 -PUBLIC CryptonightR_instruction242 -PUBLIC CryptonightR_instruction243 -PUBLIC CryptonightR_instruction244 -PUBLIC CryptonightR_instruction245 -PUBLIC CryptonightR_instruction246 -PUBLIC CryptonightR_instruction247 -PUBLIC CryptonightR_instruction248 -PUBLIC CryptonightR_instruction249 -PUBLIC CryptonightR_instruction250 -PUBLIC CryptonightR_instruction251 -PUBLIC CryptonightR_instruction252 -PUBLIC CryptonightR_instruction253 -PUBLIC CryptonightR_instruction254 -PUBLIC CryptonightR_instruction255 -PUBLIC CryptonightR_instruction256 -PUBLIC CryptonightR_instruction_mov0 -PUBLIC CryptonightR_instruction_mov1 -PUBLIC CryptonightR_instruction_mov2 -PUBLIC CryptonightR_instruction_mov3 -PUBLIC CryptonightR_instruction_mov4 -PUBLIC CryptonightR_instruction_mov5 -PUBLIC CryptonightR_instruction_mov6 -PUBLIC CryptonightR_instruction_mov7 -PUBLIC CryptonightR_instruction_mov8 -PUBLIC CryptonightR_instruction_mov9 -PUBLIC CryptonightR_instruction_mov10 -PUBLIC CryptonightR_instruction_mov11 -PUBLIC CryptonightR_instruction_mov12 -PUBLIC CryptonightR_instruction_mov13 -PUBLIC CryptonightR_instruction_mov14 -PUBLIC CryptonightR_instruction_mov15 -PUBLIC CryptonightR_instruction_mov16 -PUBLIC CryptonightR_instruction_mov17 -PUBLIC CryptonightR_instruction_mov18 -PUBLIC CryptonightR_instruction_mov19 -PUBLIC CryptonightR_instruction_mov20 -PUBLIC CryptonightR_instruction_mov21 -PUBLIC CryptonightR_instruction_mov22 -PUBLIC CryptonightR_instruction_mov23 -PUBLIC CryptonightR_instruction_mov24 -PUBLIC CryptonightR_instruction_mov25 -PUBLIC CryptonightR_instruction_mov26 -PUBLIC CryptonightR_instruction_mov27 -PUBLIC CryptonightR_instruction_mov28 -PUBLIC CryptonightR_instruction_mov29 -PUBLIC CryptonightR_instruction_mov30 -PUBLIC CryptonightR_instruction_mov31 -PUBLIC CryptonightR_instruction_mov32 -PUBLIC CryptonightR_instruction_mov33 -PUBLIC CryptonightR_instruction_mov34 -PUBLIC CryptonightR_instruction_mov35 -PUBLIC CryptonightR_instruction_mov36 -PUBLIC CryptonightR_instruction_mov37 -PUBLIC CryptonightR_instruction_mov38 -PUBLIC CryptonightR_instruction_mov39 -PUBLIC CryptonightR_instruction_mov40 -PUBLIC CryptonightR_instruction_mov41 -PUBLIC CryptonightR_instruction_mov42 -PUBLIC CryptonightR_instruction_mov43 -PUBLIC CryptonightR_instruction_mov44 -PUBLIC CryptonightR_instruction_mov45 -PUBLIC CryptonightR_instruction_mov46 -PUBLIC CryptonightR_instruction_mov47 -PUBLIC CryptonightR_instruction_mov48 -PUBLIC CryptonightR_instruction_mov49 -PUBLIC CryptonightR_instruction_mov50 -PUBLIC CryptonightR_instruction_mov51 -PUBLIC CryptonightR_instruction_mov52 -PUBLIC CryptonightR_instruction_mov53 -PUBLIC CryptonightR_instruction_mov54 -PUBLIC CryptonightR_instruction_mov55 -PUBLIC CryptonightR_instruction_mov56 -PUBLIC CryptonightR_instruction_mov57 -PUBLIC CryptonightR_instruction_mov58 -PUBLIC CryptonightR_instruction_mov59 -PUBLIC CryptonightR_instruction_mov60 -PUBLIC CryptonightR_instruction_mov61 -PUBLIC CryptonightR_instruction_mov62 -PUBLIC CryptonightR_instruction_mov63 -PUBLIC CryptonightR_instruction_mov64 -PUBLIC CryptonightR_instruction_mov65 -PUBLIC CryptonightR_instruction_mov66 -PUBLIC CryptonightR_instruction_mov67 -PUBLIC CryptonightR_instruction_mov68 -PUBLIC CryptonightR_instruction_mov69 -PUBLIC CryptonightR_instruction_mov70 -PUBLIC CryptonightR_instruction_mov71 -PUBLIC CryptonightR_instruction_mov72 -PUBLIC CryptonightR_instruction_mov73 -PUBLIC CryptonightR_instruction_mov74 -PUBLIC CryptonightR_instruction_mov75 -PUBLIC CryptonightR_instruction_mov76 -PUBLIC CryptonightR_instruction_mov77 -PUBLIC CryptonightR_instruction_mov78 -PUBLIC CryptonightR_instruction_mov79 -PUBLIC CryptonightR_instruction_mov80 -PUBLIC CryptonightR_instruction_mov81 -PUBLIC CryptonightR_instruction_mov82 -PUBLIC CryptonightR_instruction_mov83 -PUBLIC CryptonightR_instruction_mov84 -PUBLIC CryptonightR_instruction_mov85 -PUBLIC CryptonightR_instruction_mov86 -PUBLIC CryptonightR_instruction_mov87 -PUBLIC CryptonightR_instruction_mov88 -PUBLIC CryptonightR_instruction_mov89 -PUBLIC CryptonightR_instruction_mov90 -PUBLIC CryptonightR_instruction_mov91 -PUBLIC CryptonightR_instruction_mov92 -PUBLIC CryptonightR_instruction_mov93 -PUBLIC CryptonightR_instruction_mov94 -PUBLIC CryptonightR_instruction_mov95 -PUBLIC CryptonightR_instruction_mov96 -PUBLIC CryptonightR_instruction_mov97 -PUBLIC CryptonightR_instruction_mov98 -PUBLIC CryptonightR_instruction_mov99 -PUBLIC CryptonightR_instruction_mov100 -PUBLIC CryptonightR_instruction_mov101 -PUBLIC CryptonightR_instruction_mov102 -PUBLIC CryptonightR_instruction_mov103 -PUBLIC CryptonightR_instruction_mov104 -PUBLIC CryptonightR_instruction_mov105 -PUBLIC CryptonightR_instruction_mov106 -PUBLIC CryptonightR_instruction_mov107 -PUBLIC CryptonightR_instruction_mov108 -PUBLIC CryptonightR_instruction_mov109 -PUBLIC CryptonightR_instruction_mov110 -PUBLIC CryptonightR_instruction_mov111 -PUBLIC CryptonightR_instruction_mov112 -PUBLIC CryptonightR_instruction_mov113 -PUBLIC CryptonightR_instruction_mov114 -PUBLIC CryptonightR_instruction_mov115 -PUBLIC CryptonightR_instruction_mov116 -PUBLIC CryptonightR_instruction_mov117 -PUBLIC CryptonightR_instruction_mov118 -PUBLIC CryptonightR_instruction_mov119 -PUBLIC CryptonightR_instruction_mov120 -PUBLIC CryptonightR_instruction_mov121 -PUBLIC CryptonightR_instruction_mov122 -PUBLIC CryptonightR_instruction_mov123 -PUBLIC CryptonightR_instruction_mov124 -PUBLIC CryptonightR_instruction_mov125 -PUBLIC CryptonightR_instruction_mov126 -PUBLIC CryptonightR_instruction_mov127 -PUBLIC CryptonightR_instruction_mov128 -PUBLIC CryptonightR_instruction_mov129 -PUBLIC CryptonightR_instruction_mov130 -PUBLIC CryptonightR_instruction_mov131 -PUBLIC CryptonightR_instruction_mov132 -PUBLIC CryptonightR_instruction_mov133 -PUBLIC CryptonightR_instruction_mov134 -PUBLIC CryptonightR_instruction_mov135 -PUBLIC CryptonightR_instruction_mov136 -PUBLIC CryptonightR_instruction_mov137 -PUBLIC CryptonightR_instruction_mov138 -PUBLIC CryptonightR_instruction_mov139 -PUBLIC CryptonightR_instruction_mov140 -PUBLIC CryptonightR_instruction_mov141 -PUBLIC CryptonightR_instruction_mov142 -PUBLIC CryptonightR_instruction_mov143 -PUBLIC CryptonightR_instruction_mov144 -PUBLIC CryptonightR_instruction_mov145 -PUBLIC CryptonightR_instruction_mov146 -PUBLIC CryptonightR_instruction_mov147 -PUBLIC CryptonightR_instruction_mov148 -PUBLIC CryptonightR_instruction_mov149 -PUBLIC CryptonightR_instruction_mov150 -PUBLIC CryptonightR_instruction_mov151 -PUBLIC CryptonightR_instruction_mov152 -PUBLIC CryptonightR_instruction_mov153 -PUBLIC CryptonightR_instruction_mov154 -PUBLIC CryptonightR_instruction_mov155 -PUBLIC CryptonightR_instruction_mov156 -PUBLIC CryptonightR_instruction_mov157 -PUBLIC CryptonightR_instruction_mov158 -PUBLIC CryptonightR_instruction_mov159 -PUBLIC CryptonightR_instruction_mov160 -PUBLIC CryptonightR_instruction_mov161 -PUBLIC CryptonightR_instruction_mov162 -PUBLIC CryptonightR_instruction_mov163 -PUBLIC CryptonightR_instruction_mov164 -PUBLIC CryptonightR_instruction_mov165 -PUBLIC CryptonightR_instruction_mov166 -PUBLIC CryptonightR_instruction_mov167 -PUBLIC CryptonightR_instruction_mov168 -PUBLIC CryptonightR_instruction_mov169 -PUBLIC CryptonightR_instruction_mov170 -PUBLIC CryptonightR_instruction_mov171 -PUBLIC CryptonightR_instruction_mov172 -PUBLIC CryptonightR_instruction_mov173 -PUBLIC CryptonightR_instruction_mov174 -PUBLIC CryptonightR_instruction_mov175 -PUBLIC CryptonightR_instruction_mov176 -PUBLIC CryptonightR_instruction_mov177 -PUBLIC CryptonightR_instruction_mov178 -PUBLIC CryptonightR_instruction_mov179 -PUBLIC CryptonightR_instruction_mov180 -PUBLIC CryptonightR_instruction_mov181 -PUBLIC CryptonightR_instruction_mov182 -PUBLIC CryptonightR_instruction_mov183 -PUBLIC CryptonightR_instruction_mov184 -PUBLIC CryptonightR_instruction_mov185 -PUBLIC CryptonightR_instruction_mov186 -PUBLIC CryptonightR_instruction_mov187 -PUBLIC CryptonightR_instruction_mov188 -PUBLIC CryptonightR_instruction_mov189 -PUBLIC CryptonightR_instruction_mov190 -PUBLIC CryptonightR_instruction_mov191 -PUBLIC CryptonightR_instruction_mov192 -PUBLIC CryptonightR_instruction_mov193 -PUBLIC CryptonightR_instruction_mov194 -PUBLIC CryptonightR_instruction_mov195 -PUBLIC CryptonightR_instruction_mov196 -PUBLIC CryptonightR_instruction_mov197 -PUBLIC CryptonightR_instruction_mov198 -PUBLIC CryptonightR_instruction_mov199 -PUBLIC CryptonightR_instruction_mov200 -PUBLIC CryptonightR_instruction_mov201 -PUBLIC CryptonightR_instruction_mov202 -PUBLIC CryptonightR_instruction_mov203 -PUBLIC CryptonightR_instruction_mov204 -PUBLIC CryptonightR_instruction_mov205 -PUBLIC CryptonightR_instruction_mov206 -PUBLIC CryptonightR_instruction_mov207 -PUBLIC CryptonightR_instruction_mov208 -PUBLIC CryptonightR_instruction_mov209 -PUBLIC CryptonightR_instruction_mov210 -PUBLIC CryptonightR_instruction_mov211 -PUBLIC CryptonightR_instruction_mov212 -PUBLIC CryptonightR_instruction_mov213 -PUBLIC CryptonightR_instruction_mov214 -PUBLIC CryptonightR_instruction_mov215 -PUBLIC CryptonightR_instruction_mov216 -PUBLIC CryptonightR_instruction_mov217 -PUBLIC CryptonightR_instruction_mov218 -PUBLIC CryptonightR_instruction_mov219 -PUBLIC CryptonightR_instruction_mov220 -PUBLIC CryptonightR_instruction_mov221 -PUBLIC CryptonightR_instruction_mov222 -PUBLIC CryptonightR_instruction_mov223 -PUBLIC CryptonightR_instruction_mov224 -PUBLIC CryptonightR_instruction_mov225 -PUBLIC CryptonightR_instruction_mov226 -PUBLIC CryptonightR_instruction_mov227 -PUBLIC CryptonightR_instruction_mov228 -PUBLIC CryptonightR_instruction_mov229 -PUBLIC CryptonightR_instruction_mov230 -PUBLIC CryptonightR_instruction_mov231 -PUBLIC CryptonightR_instruction_mov232 -PUBLIC CryptonightR_instruction_mov233 -PUBLIC CryptonightR_instruction_mov234 -PUBLIC CryptonightR_instruction_mov235 -PUBLIC CryptonightR_instruction_mov236 -PUBLIC CryptonightR_instruction_mov237 -PUBLIC CryptonightR_instruction_mov238 -PUBLIC CryptonightR_instruction_mov239 -PUBLIC CryptonightR_instruction_mov240 -PUBLIC CryptonightR_instruction_mov241 -PUBLIC CryptonightR_instruction_mov242 -PUBLIC CryptonightR_instruction_mov243 -PUBLIC CryptonightR_instruction_mov244 -PUBLIC CryptonightR_instruction_mov245 -PUBLIC CryptonightR_instruction_mov246 -PUBLIC CryptonightR_instruction_mov247 -PUBLIC CryptonightR_instruction_mov248 -PUBLIC CryptonightR_instruction_mov249 -PUBLIC CryptonightR_instruction_mov250 -PUBLIC CryptonightR_instruction_mov251 -PUBLIC CryptonightR_instruction_mov252 -PUBLIC CryptonightR_instruction_mov253 -PUBLIC CryptonightR_instruction_mov254 -PUBLIC CryptonightR_instruction_mov255 -PUBLIC CryptonightR_instruction_mov256 - -INCLUDE CryptonightWOW_template_win.inc -INCLUDE CryptonightR_template_win.inc -INCLUDE CryptonightWOW_soft_aes_template_win.inc -INCLUDE CryptonightR_soft_aes_template_win.inc - -CryptonightR_instruction0: - imul rbx, rbx -CryptonightR_instruction1: - imul rbx, rbx -CryptonightR_instruction2: - imul rbx, rbx -CryptonightR_instruction3: - add rbx, r9 - add rbx, 2147483647 -CryptonightR_instruction4: - sub rbx, r9 -CryptonightR_instruction5: - ror ebx, cl -CryptonightR_instruction6: - rol ebx, cl -CryptonightR_instruction7: - xor rbx, r9 -CryptonightR_instruction8: - imul rsi, rbx -CryptonightR_instruction9: - imul rsi, rbx -CryptonightR_instruction10: - imul rsi, rbx -CryptonightR_instruction11: - add rsi, rbx - add rsi, 2147483647 -CryptonightR_instruction12: - sub rsi, rbx -CryptonightR_instruction13: - ror esi, cl -CryptonightR_instruction14: - rol esi, cl -CryptonightR_instruction15: - xor rsi, rbx -CryptonightR_instruction16: - imul rdi, rbx -CryptonightR_instruction17: - imul rdi, rbx -CryptonightR_instruction18: - imul rdi, rbx -CryptonightR_instruction19: - add rdi, rbx - add rdi, 2147483647 -CryptonightR_instruction20: - sub rdi, rbx -CryptonightR_instruction21: - ror edi, cl -CryptonightR_instruction22: - rol edi, cl -CryptonightR_instruction23: - xor rdi, rbx -CryptonightR_instruction24: - imul rbp, rbx -CryptonightR_instruction25: - imul rbp, rbx -CryptonightR_instruction26: - imul rbp, rbx -CryptonightR_instruction27: - add rbp, rbx - add rbp, 2147483647 -CryptonightR_instruction28: - sub rbp, rbx -CryptonightR_instruction29: - ror ebp, cl -CryptonightR_instruction30: - rol ebp, cl -CryptonightR_instruction31: - xor rbp, rbx -CryptonightR_instruction32: - imul rbx, rsi -CryptonightR_instruction33: - imul rbx, rsi -CryptonightR_instruction34: - imul rbx, rsi -CryptonightR_instruction35: - add rbx, rsi - add rbx, 2147483647 -CryptonightR_instruction36: - sub rbx, rsi -CryptonightR_instruction37: - ror ebx, cl -CryptonightR_instruction38: - rol ebx, cl -CryptonightR_instruction39: - xor rbx, rsi -CryptonightR_instruction40: - imul rsi, rsi -CryptonightR_instruction41: - imul rsi, rsi -CryptonightR_instruction42: - imul rsi, rsi -CryptonightR_instruction43: - add rsi, r9 - add rsi, 2147483647 -CryptonightR_instruction44: - sub rsi, r9 -CryptonightR_instruction45: - ror esi, cl -CryptonightR_instruction46: - rol esi, cl -CryptonightR_instruction47: - xor rsi, r9 -CryptonightR_instruction48: - imul rdi, rsi -CryptonightR_instruction49: - imul rdi, rsi -CryptonightR_instruction50: - imul rdi, rsi -CryptonightR_instruction51: - add rdi, rsi - add rdi, 2147483647 -CryptonightR_instruction52: - sub rdi, rsi -CryptonightR_instruction53: - ror edi, cl -CryptonightR_instruction54: - rol edi, cl -CryptonightR_instruction55: - xor rdi, rsi -CryptonightR_instruction56: - imul rbp, rsi -CryptonightR_instruction57: - imul rbp, rsi -CryptonightR_instruction58: - imul rbp, rsi -CryptonightR_instruction59: - add rbp, rsi - add rbp, 2147483647 -CryptonightR_instruction60: - sub rbp, rsi -CryptonightR_instruction61: - ror ebp, cl -CryptonightR_instruction62: - rol ebp, cl -CryptonightR_instruction63: - xor rbp, rsi -CryptonightR_instruction64: - imul rbx, rdi -CryptonightR_instruction65: - imul rbx, rdi -CryptonightR_instruction66: - imul rbx, rdi -CryptonightR_instruction67: - add rbx, rdi - add rbx, 2147483647 -CryptonightR_instruction68: - sub rbx, rdi -CryptonightR_instruction69: - ror ebx, cl -CryptonightR_instruction70: - rol ebx, cl -CryptonightR_instruction71: - xor rbx, rdi -CryptonightR_instruction72: - imul rsi, rdi -CryptonightR_instruction73: - imul rsi, rdi -CryptonightR_instruction74: - imul rsi, rdi -CryptonightR_instruction75: - add rsi, rdi - add rsi, 2147483647 -CryptonightR_instruction76: - sub rsi, rdi -CryptonightR_instruction77: - ror esi, cl -CryptonightR_instruction78: - rol esi, cl -CryptonightR_instruction79: - xor rsi, rdi -CryptonightR_instruction80: - imul rdi, rdi -CryptonightR_instruction81: - imul rdi, rdi -CryptonightR_instruction82: - imul rdi, rdi -CryptonightR_instruction83: - add rdi, r9 - add rdi, 2147483647 -CryptonightR_instruction84: - sub rdi, r9 -CryptonightR_instruction85: - ror edi, cl -CryptonightR_instruction86: - rol edi, cl -CryptonightR_instruction87: - xor rdi, r9 -CryptonightR_instruction88: - imul rbp, rdi -CryptonightR_instruction89: - imul rbp, rdi -CryptonightR_instruction90: - imul rbp, rdi -CryptonightR_instruction91: - add rbp, rdi - add rbp, 2147483647 -CryptonightR_instruction92: - sub rbp, rdi -CryptonightR_instruction93: - ror ebp, cl -CryptonightR_instruction94: - rol ebp, cl -CryptonightR_instruction95: - xor rbp, rdi -CryptonightR_instruction96: - imul rbx, rbp -CryptonightR_instruction97: - imul rbx, rbp -CryptonightR_instruction98: - imul rbx, rbp -CryptonightR_instruction99: - add rbx, rbp - add rbx, 2147483647 -CryptonightR_instruction100: - sub rbx, rbp -CryptonightR_instruction101: - ror ebx, cl -CryptonightR_instruction102: - rol ebx, cl -CryptonightR_instruction103: - xor rbx, rbp -CryptonightR_instruction104: - imul rsi, rbp -CryptonightR_instruction105: - imul rsi, rbp -CryptonightR_instruction106: - imul rsi, rbp -CryptonightR_instruction107: - add rsi, rbp - add rsi, 2147483647 -CryptonightR_instruction108: - sub rsi, rbp -CryptonightR_instruction109: - ror esi, cl -CryptonightR_instruction110: - rol esi, cl -CryptonightR_instruction111: - xor rsi, rbp -CryptonightR_instruction112: - imul rdi, rbp -CryptonightR_instruction113: - imul rdi, rbp -CryptonightR_instruction114: - imul rdi, rbp -CryptonightR_instruction115: - add rdi, rbp - add rdi, 2147483647 -CryptonightR_instruction116: - sub rdi, rbp -CryptonightR_instruction117: - ror edi, cl -CryptonightR_instruction118: - rol edi, cl -CryptonightR_instruction119: - xor rdi, rbp -CryptonightR_instruction120: - imul rbp, rbp -CryptonightR_instruction121: - imul rbp, rbp -CryptonightR_instruction122: - imul rbp, rbp -CryptonightR_instruction123: - add rbp, r9 - add rbp, 2147483647 -CryptonightR_instruction124: - sub rbp, r9 -CryptonightR_instruction125: - ror ebp, cl -CryptonightR_instruction126: - rol ebp, cl -CryptonightR_instruction127: - xor rbp, r9 -CryptonightR_instruction128: - imul rbx, rsp -CryptonightR_instruction129: - imul rbx, rsp -CryptonightR_instruction130: - imul rbx, rsp -CryptonightR_instruction131: - add rbx, rsp - add rbx, 2147483647 -CryptonightR_instruction132: - sub rbx, rsp -CryptonightR_instruction133: - ror ebx, cl -CryptonightR_instruction134: - rol ebx, cl -CryptonightR_instruction135: - xor rbx, rsp -CryptonightR_instruction136: - imul rsi, rsp -CryptonightR_instruction137: - imul rsi, rsp -CryptonightR_instruction138: - imul rsi, rsp -CryptonightR_instruction139: - add rsi, rsp - add rsi, 2147483647 -CryptonightR_instruction140: - sub rsi, rsp -CryptonightR_instruction141: - ror esi, cl -CryptonightR_instruction142: - rol esi, cl -CryptonightR_instruction143: - xor rsi, rsp -CryptonightR_instruction144: - imul rdi, rsp -CryptonightR_instruction145: - imul rdi, rsp -CryptonightR_instruction146: - imul rdi, rsp -CryptonightR_instruction147: - add rdi, rsp - add rdi, 2147483647 -CryptonightR_instruction148: - sub rdi, rsp -CryptonightR_instruction149: - ror edi, cl -CryptonightR_instruction150: - rol edi, cl -CryptonightR_instruction151: - xor rdi, rsp -CryptonightR_instruction152: - imul rbp, rsp -CryptonightR_instruction153: - imul rbp, rsp -CryptonightR_instruction154: - imul rbp, rsp -CryptonightR_instruction155: - add rbp, rsp - add rbp, 2147483647 -CryptonightR_instruction156: - sub rbp, rsp -CryptonightR_instruction157: - ror ebp, cl -CryptonightR_instruction158: - rol ebp, cl -CryptonightR_instruction159: - xor rbp, rsp -CryptonightR_instruction160: - imul rbx, r15 -CryptonightR_instruction161: - imul rbx, r15 -CryptonightR_instruction162: - imul rbx, r15 -CryptonightR_instruction163: - add rbx, r15 - add rbx, 2147483647 -CryptonightR_instruction164: - sub rbx, r15 -CryptonightR_instruction165: - ror ebx, cl -CryptonightR_instruction166: - rol ebx, cl -CryptonightR_instruction167: - xor rbx, r15 -CryptonightR_instruction168: - imul rsi, r15 -CryptonightR_instruction169: - imul rsi, r15 -CryptonightR_instruction170: - imul rsi, r15 -CryptonightR_instruction171: - add rsi, r15 - add rsi, 2147483647 -CryptonightR_instruction172: - sub rsi, r15 -CryptonightR_instruction173: - ror esi, cl -CryptonightR_instruction174: - rol esi, cl -CryptonightR_instruction175: - xor rsi, r15 -CryptonightR_instruction176: - imul rdi, r15 -CryptonightR_instruction177: - imul rdi, r15 -CryptonightR_instruction178: - imul rdi, r15 -CryptonightR_instruction179: - add rdi, r15 - add rdi, 2147483647 -CryptonightR_instruction180: - sub rdi, r15 -CryptonightR_instruction181: - ror edi, cl -CryptonightR_instruction182: - rol edi, cl -CryptonightR_instruction183: - xor rdi, r15 -CryptonightR_instruction184: - imul rbp, r15 -CryptonightR_instruction185: - imul rbp, r15 -CryptonightR_instruction186: - imul rbp, r15 -CryptonightR_instruction187: - add rbp, r15 - add rbp, 2147483647 -CryptonightR_instruction188: - sub rbp, r15 -CryptonightR_instruction189: - ror ebp, cl -CryptonightR_instruction190: - rol ebp, cl -CryptonightR_instruction191: - xor rbp, r15 -CryptonightR_instruction192: - imul rbx, rax -CryptonightR_instruction193: - imul rbx, rax -CryptonightR_instruction194: - imul rbx, rax -CryptonightR_instruction195: - add rbx, rax - add rbx, 2147483647 -CryptonightR_instruction196: - sub rbx, rax -CryptonightR_instruction197: - ror ebx, cl -CryptonightR_instruction198: - rol ebx, cl -CryptonightR_instruction199: - xor rbx, rax -CryptonightR_instruction200: - imul rsi, rax -CryptonightR_instruction201: - imul rsi, rax -CryptonightR_instruction202: - imul rsi, rax -CryptonightR_instruction203: - add rsi, rax - add rsi, 2147483647 -CryptonightR_instruction204: - sub rsi, rax -CryptonightR_instruction205: - ror esi, cl -CryptonightR_instruction206: - rol esi, cl -CryptonightR_instruction207: - xor rsi, rax -CryptonightR_instruction208: - imul rdi, rax -CryptonightR_instruction209: - imul rdi, rax -CryptonightR_instruction210: - imul rdi, rax -CryptonightR_instruction211: - add rdi, rax - add rdi, 2147483647 -CryptonightR_instruction212: - sub rdi, rax -CryptonightR_instruction213: - ror edi, cl -CryptonightR_instruction214: - rol edi, cl -CryptonightR_instruction215: - xor rdi, rax -CryptonightR_instruction216: - imul rbp, rax -CryptonightR_instruction217: - imul rbp, rax -CryptonightR_instruction218: - imul rbp, rax -CryptonightR_instruction219: - add rbp, rax - add rbp, 2147483647 -CryptonightR_instruction220: - sub rbp, rax -CryptonightR_instruction221: - ror ebp, cl -CryptonightR_instruction222: - rol ebp, cl -CryptonightR_instruction223: - xor rbp, rax -CryptonightR_instruction224: - imul rbx, rdx -CryptonightR_instruction225: - imul rbx, rdx -CryptonightR_instruction226: - imul rbx, rdx -CryptonightR_instruction227: - add rbx, rdx - add rbx, 2147483647 -CryptonightR_instruction228: - sub rbx, rdx -CryptonightR_instruction229: - ror ebx, cl -CryptonightR_instruction230: - rol ebx, cl -CryptonightR_instruction231: - xor rbx, rdx -CryptonightR_instruction232: - imul rsi, rdx -CryptonightR_instruction233: - imul rsi, rdx -CryptonightR_instruction234: - imul rsi, rdx -CryptonightR_instruction235: - add rsi, rdx - add rsi, 2147483647 -CryptonightR_instruction236: - sub rsi, rdx -CryptonightR_instruction237: - ror esi, cl -CryptonightR_instruction238: - rol esi, cl -CryptonightR_instruction239: - xor rsi, rdx -CryptonightR_instruction240: - imul rdi, rdx -CryptonightR_instruction241: - imul rdi, rdx -CryptonightR_instruction242: - imul rdi, rdx -CryptonightR_instruction243: - add rdi, rdx - add rdi, 2147483647 -CryptonightR_instruction244: - sub rdi, rdx -CryptonightR_instruction245: - ror edi, cl -CryptonightR_instruction246: - rol edi, cl -CryptonightR_instruction247: - xor rdi, rdx -CryptonightR_instruction248: - imul rbp, rdx -CryptonightR_instruction249: - imul rbp, rdx -CryptonightR_instruction250: - imul rbp, rdx -CryptonightR_instruction251: - add rbp, rdx - add rbp, 2147483647 -CryptonightR_instruction252: - sub rbp, rdx -CryptonightR_instruction253: - ror ebp, cl -CryptonightR_instruction254: - rol ebp, cl -CryptonightR_instruction255: - xor rbp, rdx -CryptonightR_instruction256: - imul rbx, rbx -CryptonightR_instruction_mov0: - -CryptonightR_instruction_mov1: - -CryptonightR_instruction_mov2: - -CryptonightR_instruction_mov3: - -CryptonightR_instruction_mov4: - -CryptonightR_instruction_mov5: - mov rcx, rbx -CryptonightR_instruction_mov6: - mov rcx, rbx -CryptonightR_instruction_mov7: - -CryptonightR_instruction_mov8: - -CryptonightR_instruction_mov9: - -CryptonightR_instruction_mov10: - -CryptonightR_instruction_mov11: - -CryptonightR_instruction_mov12: - -CryptonightR_instruction_mov13: - mov rcx, rbx -CryptonightR_instruction_mov14: - mov rcx, rbx -CryptonightR_instruction_mov15: - -CryptonightR_instruction_mov16: - -CryptonightR_instruction_mov17: - -CryptonightR_instruction_mov18: - -CryptonightR_instruction_mov19: - -CryptonightR_instruction_mov20: - -CryptonightR_instruction_mov21: - mov rcx, rbx -CryptonightR_instruction_mov22: - mov rcx, rbx -CryptonightR_instruction_mov23: - -CryptonightR_instruction_mov24: - -CryptonightR_instruction_mov25: - -CryptonightR_instruction_mov26: - -CryptonightR_instruction_mov27: - -CryptonightR_instruction_mov28: - -CryptonightR_instruction_mov29: - mov rcx, rbx -CryptonightR_instruction_mov30: - mov rcx, rbx -CryptonightR_instruction_mov31: - -CryptonightR_instruction_mov32: - -CryptonightR_instruction_mov33: - -CryptonightR_instruction_mov34: - -CryptonightR_instruction_mov35: - -CryptonightR_instruction_mov36: - -CryptonightR_instruction_mov37: - mov rcx, rsi -CryptonightR_instruction_mov38: - mov rcx, rsi -CryptonightR_instruction_mov39: - -CryptonightR_instruction_mov40: - -CryptonightR_instruction_mov41: - -CryptonightR_instruction_mov42: - -CryptonightR_instruction_mov43: - -CryptonightR_instruction_mov44: - -CryptonightR_instruction_mov45: - mov rcx, rsi -CryptonightR_instruction_mov46: - mov rcx, rsi -CryptonightR_instruction_mov47: - -CryptonightR_instruction_mov48: - -CryptonightR_instruction_mov49: - -CryptonightR_instruction_mov50: - -CryptonightR_instruction_mov51: - -CryptonightR_instruction_mov52: - -CryptonightR_instruction_mov53: - mov rcx, rsi -CryptonightR_instruction_mov54: - mov rcx, rsi -CryptonightR_instruction_mov55: - -CryptonightR_instruction_mov56: - -CryptonightR_instruction_mov57: - -CryptonightR_instruction_mov58: - -CryptonightR_instruction_mov59: - -CryptonightR_instruction_mov60: - -CryptonightR_instruction_mov61: - mov rcx, rsi -CryptonightR_instruction_mov62: - mov rcx, rsi -CryptonightR_instruction_mov63: - -CryptonightR_instruction_mov64: - -CryptonightR_instruction_mov65: - -CryptonightR_instruction_mov66: - -CryptonightR_instruction_mov67: - -CryptonightR_instruction_mov68: - -CryptonightR_instruction_mov69: - mov rcx, rdi -CryptonightR_instruction_mov70: - mov rcx, rdi -CryptonightR_instruction_mov71: - -CryptonightR_instruction_mov72: - -CryptonightR_instruction_mov73: - -CryptonightR_instruction_mov74: - -CryptonightR_instruction_mov75: - -CryptonightR_instruction_mov76: - -CryptonightR_instruction_mov77: - mov rcx, rdi -CryptonightR_instruction_mov78: - mov rcx, rdi -CryptonightR_instruction_mov79: - -CryptonightR_instruction_mov80: - -CryptonightR_instruction_mov81: - -CryptonightR_instruction_mov82: - -CryptonightR_instruction_mov83: - -CryptonightR_instruction_mov84: - -CryptonightR_instruction_mov85: - mov rcx, rdi -CryptonightR_instruction_mov86: - mov rcx, rdi -CryptonightR_instruction_mov87: - -CryptonightR_instruction_mov88: - -CryptonightR_instruction_mov89: - -CryptonightR_instruction_mov90: - -CryptonightR_instruction_mov91: - -CryptonightR_instruction_mov92: - -CryptonightR_instruction_mov93: - mov rcx, rdi -CryptonightR_instruction_mov94: - mov rcx, rdi -CryptonightR_instruction_mov95: - -CryptonightR_instruction_mov96: - -CryptonightR_instruction_mov97: - -CryptonightR_instruction_mov98: - -CryptonightR_instruction_mov99: - -CryptonightR_instruction_mov100: - -CryptonightR_instruction_mov101: - mov rcx, rbp -CryptonightR_instruction_mov102: - mov rcx, rbp -CryptonightR_instruction_mov103: - -CryptonightR_instruction_mov104: - -CryptonightR_instruction_mov105: - -CryptonightR_instruction_mov106: - -CryptonightR_instruction_mov107: - -CryptonightR_instruction_mov108: - -CryptonightR_instruction_mov109: - mov rcx, rbp -CryptonightR_instruction_mov110: - mov rcx, rbp -CryptonightR_instruction_mov111: - -CryptonightR_instruction_mov112: - -CryptonightR_instruction_mov113: - -CryptonightR_instruction_mov114: - -CryptonightR_instruction_mov115: - -CryptonightR_instruction_mov116: - -CryptonightR_instruction_mov117: - mov rcx, rbp -CryptonightR_instruction_mov118: - mov rcx, rbp -CryptonightR_instruction_mov119: - -CryptonightR_instruction_mov120: - -CryptonightR_instruction_mov121: - -CryptonightR_instruction_mov122: - -CryptonightR_instruction_mov123: - -CryptonightR_instruction_mov124: - -CryptonightR_instruction_mov125: - mov rcx, rbp -CryptonightR_instruction_mov126: - mov rcx, rbp -CryptonightR_instruction_mov127: - -CryptonightR_instruction_mov128: - -CryptonightR_instruction_mov129: - -CryptonightR_instruction_mov130: - -CryptonightR_instruction_mov131: - -CryptonightR_instruction_mov132: - -CryptonightR_instruction_mov133: - mov rcx, rsp -CryptonightR_instruction_mov134: - mov rcx, rsp -CryptonightR_instruction_mov135: - -CryptonightR_instruction_mov136: - -CryptonightR_instruction_mov137: - -CryptonightR_instruction_mov138: - -CryptonightR_instruction_mov139: - -CryptonightR_instruction_mov140: - -CryptonightR_instruction_mov141: - mov rcx, rsp -CryptonightR_instruction_mov142: - mov rcx, rsp -CryptonightR_instruction_mov143: - -CryptonightR_instruction_mov144: - -CryptonightR_instruction_mov145: - -CryptonightR_instruction_mov146: - -CryptonightR_instruction_mov147: - -CryptonightR_instruction_mov148: - -CryptonightR_instruction_mov149: - mov rcx, rsp -CryptonightR_instruction_mov150: - mov rcx, rsp -CryptonightR_instruction_mov151: - -CryptonightR_instruction_mov152: - -CryptonightR_instruction_mov153: - -CryptonightR_instruction_mov154: - -CryptonightR_instruction_mov155: - -CryptonightR_instruction_mov156: - -CryptonightR_instruction_mov157: - mov rcx, rsp -CryptonightR_instruction_mov158: - mov rcx, rsp -CryptonightR_instruction_mov159: - -CryptonightR_instruction_mov160: - -CryptonightR_instruction_mov161: - -CryptonightR_instruction_mov162: - -CryptonightR_instruction_mov163: - -CryptonightR_instruction_mov164: - -CryptonightR_instruction_mov165: - mov rcx, r15 -CryptonightR_instruction_mov166: - mov rcx, r15 -CryptonightR_instruction_mov167: - -CryptonightR_instruction_mov168: - -CryptonightR_instruction_mov169: - -CryptonightR_instruction_mov170: - -CryptonightR_instruction_mov171: - -CryptonightR_instruction_mov172: - -CryptonightR_instruction_mov173: - mov rcx, r15 -CryptonightR_instruction_mov174: - mov rcx, r15 -CryptonightR_instruction_mov175: - -CryptonightR_instruction_mov176: - -CryptonightR_instruction_mov177: - -CryptonightR_instruction_mov178: - -CryptonightR_instruction_mov179: - -CryptonightR_instruction_mov180: - -CryptonightR_instruction_mov181: - mov rcx, r15 -CryptonightR_instruction_mov182: - mov rcx, r15 -CryptonightR_instruction_mov183: - -CryptonightR_instruction_mov184: - -CryptonightR_instruction_mov185: - -CryptonightR_instruction_mov186: - -CryptonightR_instruction_mov187: - -CryptonightR_instruction_mov188: - -CryptonightR_instruction_mov189: - mov rcx, r15 -CryptonightR_instruction_mov190: - mov rcx, r15 -CryptonightR_instruction_mov191: - -CryptonightR_instruction_mov192: - -CryptonightR_instruction_mov193: - -CryptonightR_instruction_mov194: - -CryptonightR_instruction_mov195: - -CryptonightR_instruction_mov196: - -CryptonightR_instruction_mov197: - mov rcx, rax -CryptonightR_instruction_mov198: - mov rcx, rax -CryptonightR_instruction_mov199: - -CryptonightR_instruction_mov200: - -CryptonightR_instruction_mov201: - -CryptonightR_instruction_mov202: - -CryptonightR_instruction_mov203: - -CryptonightR_instruction_mov204: - -CryptonightR_instruction_mov205: - mov rcx, rax -CryptonightR_instruction_mov206: - mov rcx, rax -CryptonightR_instruction_mov207: - -CryptonightR_instruction_mov208: - -CryptonightR_instruction_mov209: - -CryptonightR_instruction_mov210: - -CryptonightR_instruction_mov211: - -CryptonightR_instruction_mov212: - -CryptonightR_instruction_mov213: - mov rcx, rax -CryptonightR_instruction_mov214: - mov rcx, rax -CryptonightR_instruction_mov215: - -CryptonightR_instruction_mov216: - -CryptonightR_instruction_mov217: - -CryptonightR_instruction_mov218: - -CryptonightR_instruction_mov219: - -CryptonightR_instruction_mov220: - -CryptonightR_instruction_mov221: - mov rcx, rax -CryptonightR_instruction_mov222: - mov rcx, rax -CryptonightR_instruction_mov223: - -CryptonightR_instruction_mov224: - -CryptonightR_instruction_mov225: - -CryptonightR_instruction_mov226: - -CryptonightR_instruction_mov227: - -CryptonightR_instruction_mov228: - -CryptonightR_instruction_mov229: - mov rcx, rdx -CryptonightR_instruction_mov230: - mov rcx, rdx -CryptonightR_instruction_mov231: - -CryptonightR_instruction_mov232: - -CryptonightR_instruction_mov233: - -CryptonightR_instruction_mov234: - -CryptonightR_instruction_mov235: - -CryptonightR_instruction_mov236: - -CryptonightR_instruction_mov237: - mov rcx, rdx -CryptonightR_instruction_mov238: - mov rcx, rdx -CryptonightR_instruction_mov239: - -CryptonightR_instruction_mov240: - -CryptonightR_instruction_mov241: - -CryptonightR_instruction_mov242: - -CryptonightR_instruction_mov243: - -CryptonightR_instruction_mov244: - -CryptonightR_instruction_mov245: - mov rcx, rdx -CryptonightR_instruction_mov246: - mov rcx, rdx -CryptonightR_instruction_mov247: - -CryptonightR_instruction_mov248: - -CryptonightR_instruction_mov249: - -CryptonightR_instruction_mov250: - -CryptonightR_instruction_mov251: - -CryptonightR_instruction_mov252: - -CryptonightR_instruction_mov253: - mov rcx, rdx -CryptonightR_instruction_mov254: - mov rcx, rdx -CryptonightR_instruction_mov255: - -CryptonightR_instruction_mov256: - -_TEXT_CN_TEMPLATE ENDS -END diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.h b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.h deleted file mode 100644 index c2054705b9..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.h +++ /dev/null @@ -1,1063 +0,0 @@ -// Auto-generated file, do not edit - -extern "C" -{ - void CryptonightWOW_template_part1(); - void CryptonightWOW_template_mainloop(); - void CryptonightWOW_template_part2(); - void CryptonightWOW_template_part3(); - void CryptonightWOW_template_end(); - void CryptonightWOW_template_double_part1(); - void CryptonightWOW_template_double_mainloop(); - void CryptonightWOW_template_double_part2(); - void CryptonightWOW_template_double_part3(); - void CryptonightWOW_template_double_part4(); - void CryptonightWOW_template_double_end(); - - void CryptonightR_template_part1(); - void CryptonightR_template_mainloop(); - void CryptonightR_template_part2(); - void CryptonightR_template_part3(); - void CryptonightR_template_end(); - void CryptonightR_template_double_part1(); - void CryptonightR_template_double_mainloop(); - void CryptonightR_template_double_part2(); - void CryptonightR_template_double_part3(); - void CryptonightR_template_double_part4(); - void CryptonightR_template_double_end(); - - void CryptonightR_instruction0(); - void CryptonightR_instruction1(); - void CryptonightR_instruction2(); - void CryptonightR_instruction3(); - void CryptonightR_instruction4(); - void CryptonightR_instruction5(); - void CryptonightR_instruction6(); - void CryptonightR_instruction7(); - void CryptonightR_instruction8(); - void CryptonightR_instruction9(); - void CryptonightR_instruction10(); - void CryptonightR_instruction11(); - void CryptonightR_instruction12(); - void CryptonightR_instruction13(); - void CryptonightR_instruction14(); - void CryptonightR_instruction15(); - void CryptonightR_instruction16(); - void CryptonightR_instruction17(); - void CryptonightR_instruction18(); - void CryptonightR_instruction19(); - void CryptonightR_instruction20(); - void CryptonightR_instruction21(); - void CryptonightR_instruction22(); - void CryptonightR_instruction23(); - void CryptonightR_instruction24(); - void CryptonightR_instruction25(); - void CryptonightR_instruction26(); - void CryptonightR_instruction27(); - void CryptonightR_instruction28(); - void CryptonightR_instruction29(); - void CryptonightR_instruction30(); - void CryptonightR_instruction31(); - void CryptonightR_instruction32(); - void CryptonightR_instruction33(); - void CryptonightR_instruction34(); - void CryptonightR_instruction35(); - void CryptonightR_instruction36(); - void CryptonightR_instruction37(); - void CryptonightR_instruction38(); - void CryptonightR_instruction39(); - void CryptonightR_instruction40(); - void CryptonightR_instruction41(); - void CryptonightR_instruction42(); - void CryptonightR_instruction43(); - void CryptonightR_instruction44(); - void CryptonightR_instruction45(); - void CryptonightR_instruction46(); - void CryptonightR_instruction47(); - void CryptonightR_instruction48(); - void CryptonightR_instruction49(); - void CryptonightR_instruction50(); - void CryptonightR_instruction51(); - void CryptonightR_instruction52(); - void CryptonightR_instruction53(); - void CryptonightR_instruction54(); - void CryptonightR_instruction55(); - void CryptonightR_instruction56(); - void CryptonightR_instruction57(); - void CryptonightR_instruction58(); - void CryptonightR_instruction59(); - void CryptonightR_instruction60(); - void CryptonightR_instruction61(); - void CryptonightR_instruction62(); - void CryptonightR_instruction63(); - void CryptonightR_instruction64(); - void CryptonightR_instruction65(); - void CryptonightR_instruction66(); - void CryptonightR_instruction67(); - void CryptonightR_instruction68(); - void CryptonightR_instruction69(); - void CryptonightR_instruction70(); - void CryptonightR_instruction71(); - void CryptonightR_instruction72(); - void CryptonightR_instruction73(); - void CryptonightR_instruction74(); - void CryptonightR_instruction75(); - void CryptonightR_instruction76(); - void CryptonightR_instruction77(); - void CryptonightR_instruction78(); - void CryptonightR_instruction79(); - void CryptonightR_instruction80(); - void CryptonightR_instruction81(); - void CryptonightR_instruction82(); - void CryptonightR_instruction83(); - void CryptonightR_instruction84(); - void CryptonightR_instruction85(); - void CryptonightR_instruction86(); - void CryptonightR_instruction87(); - void CryptonightR_instruction88(); - void CryptonightR_instruction89(); - void CryptonightR_instruction90(); - void CryptonightR_instruction91(); - void CryptonightR_instruction92(); - void CryptonightR_instruction93(); - void CryptonightR_instruction94(); - void CryptonightR_instruction95(); - void CryptonightR_instruction96(); - void CryptonightR_instruction97(); - void CryptonightR_instruction98(); - void CryptonightR_instruction99(); - void CryptonightR_instruction100(); - void CryptonightR_instruction101(); - void CryptonightR_instruction102(); - void CryptonightR_instruction103(); - void CryptonightR_instruction104(); - void CryptonightR_instruction105(); - void CryptonightR_instruction106(); - void CryptonightR_instruction107(); - void CryptonightR_instruction108(); - void CryptonightR_instruction109(); - void CryptonightR_instruction110(); - void CryptonightR_instruction111(); - void CryptonightR_instruction112(); - void CryptonightR_instruction113(); - void CryptonightR_instruction114(); - void CryptonightR_instruction115(); - void CryptonightR_instruction116(); - void CryptonightR_instruction117(); - void CryptonightR_instruction118(); - void CryptonightR_instruction119(); - void CryptonightR_instruction120(); - void CryptonightR_instruction121(); - void CryptonightR_instruction122(); - void CryptonightR_instruction123(); - void CryptonightR_instruction124(); - void CryptonightR_instruction125(); - void CryptonightR_instruction126(); - void CryptonightR_instruction127(); - void CryptonightR_instruction128(); - void CryptonightR_instruction129(); - void CryptonightR_instruction130(); - void CryptonightR_instruction131(); - void CryptonightR_instruction132(); - void CryptonightR_instruction133(); - void CryptonightR_instruction134(); - void CryptonightR_instruction135(); - void CryptonightR_instruction136(); - void CryptonightR_instruction137(); - void CryptonightR_instruction138(); - void CryptonightR_instruction139(); - void CryptonightR_instruction140(); - void CryptonightR_instruction141(); - void CryptonightR_instruction142(); - void CryptonightR_instruction143(); - void CryptonightR_instruction144(); - void CryptonightR_instruction145(); - void CryptonightR_instruction146(); - void CryptonightR_instruction147(); - void CryptonightR_instruction148(); - void CryptonightR_instruction149(); - void CryptonightR_instruction150(); - void CryptonightR_instruction151(); - void CryptonightR_instruction152(); - void CryptonightR_instruction153(); - void CryptonightR_instruction154(); - void CryptonightR_instruction155(); - void CryptonightR_instruction156(); - void CryptonightR_instruction157(); - void CryptonightR_instruction158(); - void CryptonightR_instruction159(); - void CryptonightR_instruction160(); - void CryptonightR_instruction161(); - void CryptonightR_instruction162(); - void CryptonightR_instruction163(); - void CryptonightR_instruction164(); - void CryptonightR_instruction165(); - void CryptonightR_instruction166(); - void CryptonightR_instruction167(); - void CryptonightR_instruction168(); - void CryptonightR_instruction169(); - void CryptonightR_instruction170(); - void CryptonightR_instruction171(); - void CryptonightR_instruction172(); - void CryptonightR_instruction173(); - void CryptonightR_instruction174(); - void CryptonightR_instruction175(); - void CryptonightR_instruction176(); - void CryptonightR_instruction177(); - void CryptonightR_instruction178(); - void CryptonightR_instruction179(); - void CryptonightR_instruction180(); - void CryptonightR_instruction181(); - void CryptonightR_instruction182(); - void CryptonightR_instruction183(); - void CryptonightR_instruction184(); - void CryptonightR_instruction185(); - void CryptonightR_instruction186(); - void CryptonightR_instruction187(); - void CryptonightR_instruction188(); - void CryptonightR_instruction189(); - void CryptonightR_instruction190(); - void CryptonightR_instruction191(); - void CryptonightR_instruction192(); - void CryptonightR_instruction193(); - void CryptonightR_instruction194(); - void CryptonightR_instruction195(); - void CryptonightR_instruction196(); - void CryptonightR_instruction197(); - void CryptonightR_instruction198(); - void CryptonightR_instruction199(); - void CryptonightR_instruction200(); - void CryptonightR_instruction201(); - void CryptonightR_instruction202(); - void CryptonightR_instruction203(); - void CryptonightR_instruction204(); - void CryptonightR_instruction205(); - void CryptonightR_instruction206(); - void CryptonightR_instruction207(); - void CryptonightR_instruction208(); - void CryptonightR_instruction209(); - void CryptonightR_instruction210(); - void CryptonightR_instruction211(); - void CryptonightR_instruction212(); - void CryptonightR_instruction213(); - void CryptonightR_instruction214(); - void CryptonightR_instruction215(); - void CryptonightR_instruction216(); - void CryptonightR_instruction217(); - void CryptonightR_instruction218(); - void CryptonightR_instruction219(); - void CryptonightR_instruction220(); - void CryptonightR_instruction221(); - void CryptonightR_instruction222(); - void CryptonightR_instruction223(); - void CryptonightR_instruction224(); - void CryptonightR_instruction225(); - void CryptonightR_instruction226(); - void CryptonightR_instruction227(); - void CryptonightR_instruction228(); - void CryptonightR_instruction229(); - void CryptonightR_instruction230(); - void CryptonightR_instruction231(); - void CryptonightR_instruction232(); - void CryptonightR_instruction233(); - void CryptonightR_instruction234(); - void CryptonightR_instruction235(); - void CryptonightR_instruction236(); - void CryptonightR_instruction237(); - void CryptonightR_instruction238(); - void CryptonightR_instruction239(); - void CryptonightR_instruction240(); - void CryptonightR_instruction241(); - void CryptonightR_instruction242(); - void CryptonightR_instruction243(); - void CryptonightR_instruction244(); - void CryptonightR_instruction245(); - void CryptonightR_instruction246(); - void CryptonightR_instruction247(); - void CryptonightR_instruction248(); - void CryptonightR_instruction249(); - void CryptonightR_instruction250(); - void CryptonightR_instruction251(); - void CryptonightR_instruction252(); - void CryptonightR_instruction253(); - void CryptonightR_instruction254(); - void CryptonightR_instruction255(); - void CryptonightR_instruction256(); - void CryptonightR_instruction_mov0(); - void CryptonightR_instruction_mov1(); - void CryptonightR_instruction_mov2(); - void CryptonightR_instruction_mov3(); - void CryptonightR_instruction_mov4(); - void CryptonightR_instruction_mov5(); - void CryptonightR_instruction_mov6(); - void CryptonightR_instruction_mov7(); - void CryptonightR_instruction_mov8(); - void CryptonightR_instruction_mov9(); - void CryptonightR_instruction_mov10(); - void CryptonightR_instruction_mov11(); - void CryptonightR_instruction_mov12(); - void CryptonightR_instruction_mov13(); - void CryptonightR_instruction_mov14(); - void CryptonightR_instruction_mov15(); - void CryptonightR_instruction_mov16(); - void CryptonightR_instruction_mov17(); - void CryptonightR_instruction_mov18(); - void CryptonightR_instruction_mov19(); - void CryptonightR_instruction_mov20(); - void CryptonightR_instruction_mov21(); - void CryptonightR_instruction_mov22(); - void CryptonightR_instruction_mov23(); - void CryptonightR_instruction_mov24(); - void CryptonightR_instruction_mov25(); - void CryptonightR_instruction_mov26(); - void CryptonightR_instruction_mov27(); - void CryptonightR_instruction_mov28(); - void CryptonightR_instruction_mov29(); - void CryptonightR_instruction_mov30(); - void CryptonightR_instruction_mov31(); - void CryptonightR_instruction_mov32(); - void CryptonightR_instruction_mov33(); - void CryptonightR_instruction_mov34(); - void CryptonightR_instruction_mov35(); - void CryptonightR_instruction_mov36(); - void CryptonightR_instruction_mov37(); - void CryptonightR_instruction_mov38(); - void CryptonightR_instruction_mov39(); - void CryptonightR_instruction_mov40(); - void CryptonightR_instruction_mov41(); - void CryptonightR_instruction_mov42(); - void CryptonightR_instruction_mov43(); - void CryptonightR_instruction_mov44(); - void CryptonightR_instruction_mov45(); - void CryptonightR_instruction_mov46(); - void CryptonightR_instruction_mov47(); - void CryptonightR_instruction_mov48(); - void CryptonightR_instruction_mov49(); - void CryptonightR_instruction_mov50(); - void CryptonightR_instruction_mov51(); - void CryptonightR_instruction_mov52(); - void CryptonightR_instruction_mov53(); - void CryptonightR_instruction_mov54(); - void CryptonightR_instruction_mov55(); - void CryptonightR_instruction_mov56(); - void CryptonightR_instruction_mov57(); - void CryptonightR_instruction_mov58(); - void CryptonightR_instruction_mov59(); - void CryptonightR_instruction_mov60(); - void CryptonightR_instruction_mov61(); - void CryptonightR_instruction_mov62(); - void CryptonightR_instruction_mov63(); - void CryptonightR_instruction_mov64(); - void CryptonightR_instruction_mov65(); - void CryptonightR_instruction_mov66(); - void CryptonightR_instruction_mov67(); - void CryptonightR_instruction_mov68(); - void CryptonightR_instruction_mov69(); - void CryptonightR_instruction_mov70(); - void CryptonightR_instruction_mov71(); - void CryptonightR_instruction_mov72(); - void CryptonightR_instruction_mov73(); - void CryptonightR_instruction_mov74(); - void CryptonightR_instruction_mov75(); - void CryptonightR_instruction_mov76(); - void CryptonightR_instruction_mov77(); - void CryptonightR_instruction_mov78(); - void CryptonightR_instruction_mov79(); - void CryptonightR_instruction_mov80(); - void CryptonightR_instruction_mov81(); - void CryptonightR_instruction_mov82(); - void CryptonightR_instruction_mov83(); - void CryptonightR_instruction_mov84(); - void CryptonightR_instruction_mov85(); - void CryptonightR_instruction_mov86(); - void CryptonightR_instruction_mov87(); - void CryptonightR_instruction_mov88(); - void CryptonightR_instruction_mov89(); - void CryptonightR_instruction_mov90(); - void CryptonightR_instruction_mov91(); - void CryptonightR_instruction_mov92(); - void CryptonightR_instruction_mov93(); - void CryptonightR_instruction_mov94(); - void CryptonightR_instruction_mov95(); - void CryptonightR_instruction_mov96(); - void CryptonightR_instruction_mov97(); - void CryptonightR_instruction_mov98(); - void CryptonightR_instruction_mov99(); - void CryptonightR_instruction_mov100(); - void CryptonightR_instruction_mov101(); - void CryptonightR_instruction_mov102(); - void CryptonightR_instruction_mov103(); - void CryptonightR_instruction_mov104(); - void CryptonightR_instruction_mov105(); - void CryptonightR_instruction_mov106(); - void CryptonightR_instruction_mov107(); - void CryptonightR_instruction_mov108(); - void CryptonightR_instruction_mov109(); - void CryptonightR_instruction_mov110(); - void CryptonightR_instruction_mov111(); - void CryptonightR_instruction_mov112(); - void CryptonightR_instruction_mov113(); - void CryptonightR_instruction_mov114(); - void CryptonightR_instruction_mov115(); - void CryptonightR_instruction_mov116(); - void CryptonightR_instruction_mov117(); - void CryptonightR_instruction_mov118(); - void CryptonightR_instruction_mov119(); - void CryptonightR_instruction_mov120(); - void CryptonightR_instruction_mov121(); - void CryptonightR_instruction_mov122(); - void CryptonightR_instruction_mov123(); - void CryptonightR_instruction_mov124(); - void CryptonightR_instruction_mov125(); - void CryptonightR_instruction_mov126(); - void CryptonightR_instruction_mov127(); - void CryptonightR_instruction_mov128(); - void CryptonightR_instruction_mov129(); - void CryptonightR_instruction_mov130(); - void CryptonightR_instruction_mov131(); - void CryptonightR_instruction_mov132(); - void CryptonightR_instruction_mov133(); - void CryptonightR_instruction_mov134(); - void CryptonightR_instruction_mov135(); - void CryptonightR_instruction_mov136(); - void CryptonightR_instruction_mov137(); - void CryptonightR_instruction_mov138(); - void CryptonightR_instruction_mov139(); - void CryptonightR_instruction_mov140(); - void CryptonightR_instruction_mov141(); - void CryptonightR_instruction_mov142(); - void CryptonightR_instruction_mov143(); - void CryptonightR_instruction_mov144(); - void CryptonightR_instruction_mov145(); - void CryptonightR_instruction_mov146(); - void CryptonightR_instruction_mov147(); - void CryptonightR_instruction_mov148(); - void CryptonightR_instruction_mov149(); - void CryptonightR_instruction_mov150(); - void CryptonightR_instruction_mov151(); - void CryptonightR_instruction_mov152(); - void CryptonightR_instruction_mov153(); - void CryptonightR_instruction_mov154(); - void CryptonightR_instruction_mov155(); - void CryptonightR_instruction_mov156(); - void CryptonightR_instruction_mov157(); - void CryptonightR_instruction_mov158(); - void CryptonightR_instruction_mov159(); - void CryptonightR_instruction_mov160(); - void CryptonightR_instruction_mov161(); - void CryptonightR_instruction_mov162(); - void CryptonightR_instruction_mov163(); - void CryptonightR_instruction_mov164(); - void CryptonightR_instruction_mov165(); - void CryptonightR_instruction_mov166(); - void CryptonightR_instruction_mov167(); - void CryptonightR_instruction_mov168(); - void CryptonightR_instruction_mov169(); - void CryptonightR_instruction_mov170(); - void CryptonightR_instruction_mov171(); - void CryptonightR_instruction_mov172(); - void CryptonightR_instruction_mov173(); - void CryptonightR_instruction_mov174(); - void CryptonightR_instruction_mov175(); - void CryptonightR_instruction_mov176(); - void CryptonightR_instruction_mov177(); - void CryptonightR_instruction_mov178(); - void CryptonightR_instruction_mov179(); - void CryptonightR_instruction_mov180(); - void CryptonightR_instruction_mov181(); - void CryptonightR_instruction_mov182(); - void CryptonightR_instruction_mov183(); - void CryptonightR_instruction_mov184(); - void CryptonightR_instruction_mov185(); - void CryptonightR_instruction_mov186(); - void CryptonightR_instruction_mov187(); - void CryptonightR_instruction_mov188(); - void CryptonightR_instruction_mov189(); - void CryptonightR_instruction_mov190(); - void CryptonightR_instruction_mov191(); - void CryptonightR_instruction_mov192(); - void CryptonightR_instruction_mov193(); - void CryptonightR_instruction_mov194(); - void CryptonightR_instruction_mov195(); - void CryptonightR_instruction_mov196(); - void CryptonightR_instruction_mov197(); - void CryptonightR_instruction_mov198(); - void CryptonightR_instruction_mov199(); - void CryptonightR_instruction_mov200(); - void CryptonightR_instruction_mov201(); - void CryptonightR_instruction_mov202(); - void CryptonightR_instruction_mov203(); - void CryptonightR_instruction_mov204(); - void CryptonightR_instruction_mov205(); - void CryptonightR_instruction_mov206(); - void CryptonightR_instruction_mov207(); - void CryptonightR_instruction_mov208(); - void CryptonightR_instruction_mov209(); - void CryptonightR_instruction_mov210(); - void CryptonightR_instruction_mov211(); - void CryptonightR_instruction_mov212(); - void CryptonightR_instruction_mov213(); - void CryptonightR_instruction_mov214(); - void CryptonightR_instruction_mov215(); - void CryptonightR_instruction_mov216(); - void CryptonightR_instruction_mov217(); - void CryptonightR_instruction_mov218(); - void CryptonightR_instruction_mov219(); - void CryptonightR_instruction_mov220(); - void CryptonightR_instruction_mov221(); - void CryptonightR_instruction_mov222(); - void CryptonightR_instruction_mov223(); - void CryptonightR_instruction_mov224(); - void CryptonightR_instruction_mov225(); - void CryptonightR_instruction_mov226(); - void CryptonightR_instruction_mov227(); - void CryptonightR_instruction_mov228(); - void CryptonightR_instruction_mov229(); - void CryptonightR_instruction_mov230(); - void CryptonightR_instruction_mov231(); - void CryptonightR_instruction_mov232(); - void CryptonightR_instruction_mov233(); - void CryptonightR_instruction_mov234(); - void CryptonightR_instruction_mov235(); - void CryptonightR_instruction_mov236(); - void CryptonightR_instruction_mov237(); - void CryptonightR_instruction_mov238(); - void CryptonightR_instruction_mov239(); - void CryptonightR_instruction_mov240(); - void CryptonightR_instruction_mov241(); - void CryptonightR_instruction_mov242(); - void CryptonightR_instruction_mov243(); - void CryptonightR_instruction_mov244(); - void CryptonightR_instruction_mov245(); - void CryptonightR_instruction_mov246(); - void CryptonightR_instruction_mov247(); - void CryptonightR_instruction_mov248(); - void CryptonightR_instruction_mov249(); - void CryptonightR_instruction_mov250(); - void CryptonightR_instruction_mov251(); - void CryptonightR_instruction_mov252(); - void CryptonightR_instruction_mov253(); - void CryptonightR_instruction_mov254(); - void CryptonightR_instruction_mov255(); - void CryptonightR_instruction_mov256(); -} - -const void_func instructions[257] = { - CryptonightR_instruction0, - CryptonightR_instruction1, - CryptonightR_instruction2, - CryptonightR_instruction3, - CryptonightR_instruction4, - CryptonightR_instruction5, - CryptonightR_instruction6, - CryptonightR_instruction7, - CryptonightR_instruction8, - CryptonightR_instruction9, - CryptonightR_instruction10, - CryptonightR_instruction11, - CryptonightR_instruction12, - CryptonightR_instruction13, - CryptonightR_instruction14, - CryptonightR_instruction15, - CryptonightR_instruction16, - CryptonightR_instruction17, - CryptonightR_instruction18, - CryptonightR_instruction19, - CryptonightR_instruction20, - CryptonightR_instruction21, - CryptonightR_instruction22, - CryptonightR_instruction23, - CryptonightR_instruction24, - CryptonightR_instruction25, - CryptonightR_instruction26, - CryptonightR_instruction27, - CryptonightR_instruction28, - CryptonightR_instruction29, - CryptonightR_instruction30, - CryptonightR_instruction31, - CryptonightR_instruction32, - CryptonightR_instruction33, - CryptonightR_instruction34, - CryptonightR_instruction35, - CryptonightR_instruction36, - CryptonightR_instruction37, - CryptonightR_instruction38, - CryptonightR_instruction39, - CryptonightR_instruction40, - CryptonightR_instruction41, - CryptonightR_instruction42, - CryptonightR_instruction43, - CryptonightR_instruction44, - CryptonightR_instruction45, - CryptonightR_instruction46, - CryptonightR_instruction47, - CryptonightR_instruction48, - CryptonightR_instruction49, - CryptonightR_instruction50, - CryptonightR_instruction51, - CryptonightR_instruction52, - CryptonightR_instruction53, - CryptonightR_instruction54, - CryptonightR_instruction55, - CryptonightR_instruction56, - CryptonightR_instruction57, - CryptonightR_instruction58, - CryptonightR_instruction59, - CryptonightR_instruction60, - CryptonightR_instruction61, - CryptonightR_instruction62, - CryptonightR_instruction63, - CryptonightR_instruction64, - CryptonightR_instruction65, - CryptonightR_instruction66, - CryptonightR_instruction67, - CryptonightR_instruction68, - CryptonightR_instruction69, - CryptonightR_instruction70, - CryptonightR_instruction71, - CryptonightR_instruction72, - CryptonightR_instruction73, - CryptonightR_instruction74, - CryptonightR_instruction75, - CryptonightR_instruction76, - CryptonightR_instruction77, - CryptonightR_instruction78, - CryptonightR_instruction79, - CryptonightR_instruction80, - CryptonightR_instruction81, - CryptonightR_instruction82, - CryptonightR_instruction83, - CryptonightR_instruction84, - CryptonightR_instruction85, - CryptonightR_instruction86, - CryptonightR_instruction87, - CryptonightR_instruction88, - CryptonightR_instruction89, - CryptonightR_instruction90, - CryptonightR_instruction91, - CryptonightR_instruction92, - CryptonightR_instruction93, - CryptonightR_instruction94, - CryptonightR_instruction95, - CryptonightR_instruction96, - CryptonightR_instruction97, - CryptonightR_instruction98, - CryptonightR_instruction99, - CryptonightR_instruction100, - CryptonightR_instruction101, - CryptonightR_instruction102, - CryptonightR_instruction103, - CryptonightR_instruction104, - CryptonightR_instruction105, - CryptonightR_instruction106, - CryptonightR_instruction107, - CryptonightR_instruction108, - CryptonightR_instruction109, - CryptonightR_instruction110, - CryptonightR_instruction111, - CryptonightR_instruction112, - CryptonightR_instruction113, - CryptonightR_instruction114, - CryptonightR_instruction115, - CryptonightR_instruction116, - CryptonightR_instruction117, - CryptonightR_instruction118, - CryptonightR_instruction119, - CryptonightR_instruction120, - CryptonightR_instruction121, - CryptonightR_instruction122, - CryptonightR_instruction123, - CryptonightR_instruction124, - CryptonightR_instruction125, - CryptonightR_instruction126, - CryptonightR_instruction127, - CryptonightR_instruction128, - CryptonightR_instruction129, - CryptonightR_instruction130, - CryptonightR_instruction131, - CryptonightR_instruction132, - CryptonightR_instruction133, - CryptonightR_instruction134, - CryptonightR_instruction135, - CryptonightR_instruction136, - CryptonightR_instruction137, - CryptonightR_instruction138, - CryptonightR_instruction139, - CryptonightR_instruction140, - CryptonightR_instruction141, - CryptonightR_instruction142, - CryptonightR_instruction143, - CryptonightR_instruction144, - CryptonightR_instruction145, - CryptonightR_instruction146, - CryptonightR_instruction147, - CryptonightR_instruction148, - CryptonightR_instruction149, - CryptonightR_instruction150, - CryptonightR_instruction151, - CryptonightR_instruction152, - CryptonightR_instruction153, - CryptonightR_instruction154, - CryptonightR_instruction155, - CryptonightR_instruction156, - CryptonightR_instruction157, - CryptonightR_instruction158, - CryptonightR_instruction159, - CryptonightR_instruction160, - CryptonightR_instruction161, - CryptonightR_instruction162, - CryptonightR_instruction163, - CryptonightR_instruction164, - CryptonightR_instruction165, - CryptonightR_instruction166, - CryptonightR_instruction167, - CryptonightR_instruction168, - CryptonightR_instruction169, - CryptonightR_instruction170, - CryptonightR_instruction171, - CryptonightR_instruction172, - CryptonightR_instruction173, - CryptonightR_instruction174, - CryptonightR_instruction175, - CryptonightR_instruction176, - CryptonightR_instruction177, - CryptonightR_instruction178, - CryptonightR_instruction179, - CryptonightR_instruction180, - CryptonightR_instruction181, - CryptonightR_instruction182, - CryptonightR_instruction183, - CryptonightR_instruction184, - CryptonightR_instruction185, - CryptonightR_instruction186, - CryptonightR_instruction187, - CryptonightR_instruction188, - CryptonightR_instruction189, - CryptonightR_instruction190, - CryptonightR_instruction191, - CryptonightR_instruction192, - CryptonightR_instruction193, - CryptonightR_instruction194, - CryptonightR_instruction195, - CryptonightR_instruction196, - CryptonightR_instruction197, - CryptonightR_instruction198, - CryptonightR_instruction199, - CryptonightR_instruction200, - CryptonightR_instruction201, - CryptonightR_instruction202, - CryptonightR_instruction203, - CryptonightR_instruction204, - CryptonightR_instruction205, - CryptonightR_instruction206, - CryptonightR_instruction207, - CryptonightR_instruction208, - CryptonightR_instruction209, - CryptonightR_instruction210, - CryptonightR_instruction211, - CryptonightR_instruction212, - CryptonightR_instruction213, - CryptonightR_instruction214, - CryptonightR_instruction215, - CryptonightR_instruction216, - CryptonightR_instruction217, - CryptonightR_instruction218, - CryptonightR_instruction219, - CryptonightR_instruction220, - CryptonightR_instruction221, - CryptonightR_instruction222, - CryptonightR_instruction223, - CryptonightR_instruction224, - CryptonightR_instruction225, - CryptonightR_instruction226, - CryptonightR_instruction227, - CryptonightR_instruction228, - CryptonightR_instruction229, - CryptonightR_instruction230, - CryptonightR_instruction231, - CryptonightR_instruction232, - CryptonightR_instruction233, - CryptonightR_instruction234, - CryptonightR_instruction235, - CryptonightR_instruction236, - CryptonightR_instruction237, - CryptonightR_instruction238, - CryptonightR_instruction239, - CryptonightR_instruction240, - CryptonightR_instruction241, - CryptonightR_instruction242, - CryptonightR_instruction243, - CryptonightR_instruction244, - CryptonightR_instruction245, - CryptonightR_instruction246, - CryptonightR_instruction247, - CryptonightR_instruction248, - CryptonightR_instruction249, - CryptonightR_instruction250, - CryptonightR_instruction251, - CryptonightR_instruction252, - CryptonightR_instruction253, - CryptonightR_instruction254, - CryptonightR_instruction255, - CryptonightR_instruction256, -}; - -const void_func instructions_mov[257] = { - CryptonightR_instruction_mov0, - CryptonightR_instruction_mov1, - CryptonightR_instruction_mov2, - CryptonightR_instruction_mov3, - CryptonightR_instruction_mov4, - CryptonightR_instruction_mov5, - CryptonightR_instruction_mov6, - CryptonightR_instruction_mov7, - CryptonightR_instruction_mov8, - CryptonightR_instruction_mov9, - CryptonightR_instruction_mov10, - CryptonightR_instruction_mov11, - CryptonightR_instruction_mov12, - CryptonightR_instruction_mov13, - CryptonightR_instruction_mov14, - CryptonightR_instruction_mov15, - CryptonightR_instruction_mov16, - CryptonightR_instruction_mov17, - CryptonightR_instruction_mov18, - CryptonightR_instruction_mov19, - CryptonightR_instruction_mov20, - CryptonightR_instruction_mov21, - CryptonightR_instruction_mov22, - CryptonightR_instruction_mov23, - CryptonightR_instruction_mov24, - CryptonightR_instruction_mov25, - CryptonightR_instruction_mov26, - CryptonightR_instruction_mov27, - CryptonightR_instruction_mov28, - CryptonightR_instruction_mov29, - CryptonightR_instruction_mov30, - CryptonightR_instruction_mov31, - CryptonightR_instruction_mov32, - CryptonightR_instruction_mov33, - CryptonightR_instruction_mov34, - CryptonightR_instruction_mov35, - CryptonightR_instruction_mov36, - CryptonightR_instruction_mov37, - CryptonightR_instruction_mov38, - CryptonightR_instruction_mov39, - CryptonightR_instruction_mov40, - CryptonightR_instruction_mov41, - CryptonightR_instruction_mov42, - CryptonightR_instruction_mov43, - CryptonightR_instruction_mov44, - CryptonightR_instruction_mov45, - CryptonightR_instruction_mov46, - CryptonightR_instruction_mov47, - CryptonightR_instruction_mov48, - CryptonightR_instruction_mov49, - CryptonightR_instruction_mov50, - CryptonightR_instruction_mov51, - CryptonightR_instruction_mov52, - CryptonightR_instruction_mov53, - CryptonightR_instruction_mov54, - CryptonightR_instruction_mov55, - CryptonightR_instruction_mov56, - CryptonightR_instruction_mov57, - CryptonightR_instruction_mov58, - CryptonightR_instruction_mov59, - CryptonightR_instruction_mov60, - CryptonightR_instruction_mov61, - CryptonightR_instruction_mov62, - CryptonightR_instruction_mov63, - CryptonightR_instruction_mov64, - CryptonightR_instruction_mov65, - CryptonightR_instruction_mov66, - CryptonightR_instruction_mov67, - CryptonightR_instruction_mov68, - CryptonightR_instruction_mov69, - CryptonightR_instruction_mov70, - CryptonightR_instruction_mov71, - CryptonightR_instruction_mov72, - CryptonightR_instruction_mov73, - CryptonightR_instruction_mov74, - CryptonightR_instruction_mov75, - CryptonightR_instruction_mov76, - CryptonightR_instruction_mov77, - CryptonightR_instruction_mov78, - CryptonightR_instruction_mov79, - CryptonightR_instruction_mov80, - CryptonightR_instruction_mov81, - CryptonightR_instruction_mov82, - CryptonightR_instruction_mov83, - CryptonightR_instruction_mov84, - CryptonightR_instruction_mov85, - CryptonightR_instruction_mov86, - CryptonightR_instruction_mov87, - CryptonightR_instruction_mov88, - CryptonightR_instruction_mov89, - CryptonightR_instruction_mov90, - CryptonightR_instruction_mov91, - CryptonightR_instruction_mov92, - CryptonightR_instruction_mov93, - CryptonightR_instruction_mov94, - CryptonightR_instruction_mov95, - CryptonightR_instruction_mov96, - CryptonightR_instruction_mov97, - CryptonightR_instruction_mov98, - CryptonightR_instruction_mov99, - CryptonightR_instruction_mov100, - CryptonightR_instruction_mov101, - CryptonightR_instruction_mov102, - CryptonightR_instruction_mov103, - CryptonightR_instruction_mov104, - CryptonightR_instruction_mov105, - CryptonightR_instruction_mov106, - CryptonightR_instruction_mov107, - CryptonightR_instruction_mov108, - CryptonightR_instruction_mov109, - CryptonightR_instruction_mov110, - CryptonightR_instruction_mov111, - CryptonightR_instruction_mov112, - CryptonightR_instruction_mov113, - CryptonightR_instruction_mov114, - CryptonightR_instruction_mov115, - CryptonightR_instruction_mov116, - CryptonightR_instruction_mov117, - CryptonightR_instruction_mov118, - CryptonightR_instruction_mov119, - CryptonightR_instruction_mov120, - CryptonightR_instruction_mov121, - CryptonightR_instruction_mov122, - CryptonightR_instruction_mov123, - CryptonightR_instruction_mov124, - CryptonightR_instruction_mov125, - CryptonightR_instruction_mov126, - CryptonightR_instruction_mov127, - CryptonightR_instruction_mov128, - CryptonightR_instruction_mov129, - CryptonightR_instruction_mov130, - CryptonightR_instruction_mov131, - CryptonightR_instruction_mov132, - CryptonightR_instruction_mov133, - CryptonightR_instruction_mov134, - CryptonightR_instruction_mov135, - CryptonightR_instruction_mov136, - CryptonightR_instruction_mov137, - CryptonightR_instruction_mov138, - CryptonightR_instruction_mov139, - CryptonightR_instruction_mov140, - CryptonightR_instruction_mov141, - CryptonightR_instruction_mov142, - CryptonightR_instruction_mov143, - CryptonightR_instruction_mov144, - CryptonightR_instruction_mov145, - CryptonightR_instruction_mov146, - CryptonightR_instruction_mov147, - CryptonightR_instruction_mov148, - CryptonightR_instruction_mov149, - CryptonightR_instruction_mov150, - CryptonightR_instruction_mov151, - CryptonightR_instruction_mov152, - CryptonightR_instruction_mov153, - CryptonightR_instruction_mov154, - CryptonightR_instruction_mov155, - CryptonightR_instruction_mov156, - CryptonightR_instruction_mov157, - CryptonightR_instruction_mov158, - CryptonightR_instruction_mov159, - CryptonightR_instruction_mov160, - CryptonightR_instruction_mov161, - CryptonightR_instruction_mov162, - CryptonightR_instruction_mov163, - CryptonightR_instruction_mov164, - CryptonightR_instruction_mov165, - CryptonightR_instruction_mov166, - CryptonightR_instruction_mov167, - CryptonightR_instruction_mov168, - CryptonightR_instruction_mov169, - CryptonightR_instruction_mov170, - CryptonightR_instruction_mov171, - CryptonightR_instruction_mov172, - CryptonightR_instruction_mov173, - CryptonightR_instruction_mov174, - CryptonightR_instruction_mov175, - CryptonightR_instruction_mov176, - CryptonightR_instruction_mov177, - CryptonightR_instruction_mov178, - CryptonightR_instruction_mov179, - CryptonightR_instruction_mov180, - CryptonightR_instruction_mov181, - CryptonightR_instruction_mov182, - CryptonightR_instruction_mov183, - CryptonightR_instruction_mov184, - CryptonightR_instruction_mov185, - CryptonightR_instruction_mov186, - CryptonightR_instruction_mov187, - CryptonightR_instruction_mov188, - CryptonightR_instruction_mov189, - CryptonightR_instruction_mov190, - CryptonightR_instruction_mov191, - CryptonightR_instruction_mov192, - CryptonightR_instruction_mov193, - CryptonightR_instruction_mov194, - CryptonightR_instruction_mov195, - CryptonightR_instruction_mov196, - CryptonightR_instruction_mov197, - CryptonightR_instruction_mov198, - CryptonightR_instruction_mov199, - CryptonightR_instruction_mov200, - CryptonightR_instruction_mov201, - CryptonightR_instruction_mov202, - CryptonightR_instruction_mov203, - CryptonightR_instruction_mov204, - CryptonightR_instruction_mov205, - CryptonightR_instruction_mov206, - CryptonightR_instruction_mov207, - CryptonightR_instruction_mov208, - CryptonightR_instruction_mov209, - CryptonightR_instruction_mov210, - CryptonightR_instruction_mov211, - CryptonightR_instruction_mov212, - CryptonightR_instruction_mov213, - CryptonightR_instruction_mov214, - CryptonightR_instruction_mov215, - CryptonightR_instruction_mov216, - CryptonightR_instruction_mov217, - CryptonightR_instruction_mov218, - CryptonightR_instruction_mov219, - CryptonightR_instruction_mov220, - CryptonightR_instruction_mov221, - CryptonightR_instruction_mov222, - CryptonightR_instruction_mov223, - CryptonightR_instruction_mov224, - CryptonightR_instruction_mov225, - CryptonightR_instruction_mov226, - CryptonightR_instruction_mov227, - CryptonightR_instruction_mov228, - CryptonightR_instruction_mov229, - CryptonightR_instruction_mov230, - CryptonightR_instruction_mov231, - CryptonightR_instruction_mov232, - CryptonightR_instruction_mov233, - CryptonightR_instruction_mov234, - CryptonightR_instruction_mov235, - CryptonightR_instruction_mov236, - CryptonightR_instruction_mov237, - CryptonightR_instruction_mov238, - CryptonightR_instruction_mov239, - CryptonightR_instruction_mov240, - CryptonightR_instruction_mov241, - CryptonightR_instruction_mov242, - CryptonightR_instruction_mov243, - CryptonightR_instruction_mov244, - CryptonightR_instruction_mov245, - CryptonightR_instruction_mov246, - CryptonightR_instruction_mov247, - CryptonightR_instruction_mov248, - CryptonightR_instruction_mov249, - CryptonightR_instruction_mov250, - CryptonightR_instruction_mov251, - CryptonightR_instruction_mov252, - CryptonightR_instruction_mov253, - CryptonightR_instruction_mov254, - CryptonightR_instruction_mov255, - CryptonightR_instruction_mov256, -}; diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.inc deleted file mode 100644 index 1dae434a2b..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template.inc +++ /dev/null @@ -1,529 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightR_template_part1) -PUBLIC FN_PREFIX(CryptonightR_template_mainloop) -PUBLIC FN_PREFIX(CryptonightR_template_part2) -PUBLIC FN_PREFIX(CryptonightR_template_part3) -PUBLIC FN_PREFIX(CryptonightR_template_end) -PUBLIC FN_PREFIX(CryptonightR_template_double_part1) -PUBLIC FN_PREFIX(CryptonightR_template_double_mainloop) -PUBLIC FN_PREFIX(CryptonightR_template_double_part2) -PUBLIC FN_PREFIX(CryptonightR_template_double_part3) -PUBLIC FN_PREFIX(CryptonightR_template_double_part4) -PUBLIC FN_PREFIX(CryptonightR_template_double_end) - -ALIGN(64) -FN_PREFIX(CryptonightR_template_part1): - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movd xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movd xmm0, r12 - movd xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movd xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -FN_PREFIX(CryptonightR_template_mainloop): - movdqa xmm5, XMMWORD PTR [r9+r11] - movd xmm0, r15 - movd xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - - mov r12d, r9d - mov eax, r9d - xor r9d, 48 - xor r12d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movaps xmm3, xmm0 - movdqu xmm2, XMMWORD PTR [r12+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - pxor xmm0, xmm2 - pxor xmm5, xmm1 - pxor xmm5, xmm0 - paddq xmm3, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r12+r11], xmm3 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movd r12, xmm5 - movd r10d, xmm5 - and r10d, 2097136 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - -FN_PREFIX(CryptonightR_template_part2): - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor rsp, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov rax, r13 - mul r12 - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - movaps xmm3, xmm1 - movdqa xmm2, XMMWORD PTR [r9+r11] - movdqa xmm0, XMMWORD PTR [r10+r11] - pxor xmm1, xmm2 - pxor xmm5, xmm0 - pxor xmm5, xmm1 - paddq xmm3, xmm4 - paddq xmm2, xmm6 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqu XMMWORD PTR [r12+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm3 - - movdqa xmm7, xmm6 - add r15, rax - add rsp, rdx - xor r10, 48 - mov QWORD PTR [r10+r11], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [r10+r11+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz FN_PREFIX(CryptonightR_template_mainloop) - -FN_PREFIX(CryptonightR_template_part3): - movd rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -FN_PREFIX(CryptonightR_template_end): - -ALIGN(64) -FN_PREFIX(CryptonightR_template_double_part1): - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movd xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movd xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movd xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movd xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movd xmm0, rcx - mov r11d, 524288 - movd xmm10, rax - punpcklqdq xmm10, xmm0 - - movd xmm14, QWORD PTR [rsp+128] - movd xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -FN_PREFIX(CryptonightR_template_double_mainloop): - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movd xmm0, r12 - mov ecx, ebx - movd xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movd xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm1 - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - movd rdx, xmm6 - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movd xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm1 - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movd rdi, xmm5 - movd rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movd xmm0, rsp - movd xmm1, rsi - movd xmm2, rdi - movd xmm11, rbp - movd xmm12, r15 - movd xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -FN_PREFIX(CryptonightR_template_double_part2): - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r14, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r12, rax - - movd rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movd rsi, xmm1 - movd rdi, xmm2 - movd rbp, xmm11 - movd r15, xmm12 - movd rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movdqu xmm1, XMMWORD PTR [rcx+rsi] - pxor xmm6, xmm1 - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - pxor xmm6, xmm2 - paddq xmm2, xmm3 - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - pxor xmm6, xmm0 - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movd rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movd xmm0, rsp - movd xmm1, rbx - movd xmm2, rsi - movd xmm11, rdi - movd xmm12, rbp - movd xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movd xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -FN_PREFIX(CryptonightR_template_double_part3): - - movd r15, xmm13 - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r13, rax - - movd rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movd rbx, xmm1 - movd rsi, xmm2 - movd rdi, xmm11 - movd rbp, xmm12 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - mov rdi, rcx - mov r8, rax - movdqu xmm1, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm1 - xor ebp, 48 - paddq xmm1, xmm8 - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm2 - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movd rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz FN_PREFIX(CryptonightR_template_double_mainloop) - -FN_PREFIX(CryptonightR_template_double_part4): - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -FN_PREFIX(CryptonightR_template_double_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template_win.inc deleted file mode 100644 index 60ee3441b5..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightR_template_win.inc +++ /dev/null @@ -1,531 +0,0 @@ -PUBLIC CryptonightR_template_part1 -PUBLIC CryptonightR_template_mainloop -PUBLIC CryptonightR_template_part2 -PUBLIC CryptonightR_template_part3 -PUBLIC CryptonightR_template_end -PUBLIC CryptonightR_template_double_part1 -PUBLIC CryptonightR_template_double_mainloop -PUBLIC CryptonightR_template_double_part2 -PUBLIC CryptonightR_template_double_part3 -PUBLIC CryptonightR_template_double_part4 -PUBLIC CryptonightR_template_double_end - -ALIGN(64) -CryptonightR_template_part1: - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movd xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movd xmm0, r12 - movd xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movd xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -CryptonightR_template_mainloop: - movdqa xmm5, XMMWORD PTR [r9+r11] - movd xmm0, r15 - movd xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - - mov r13d, r9d - mov eax, r9d - xor r9d, 48 - xor r13d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movaps xmm3, xmm0 - movdqu xmm2, XMMWORD PTR [r13+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - pxor xmm0, xmm2 - pxor xmm5, xmm1 - pxor xmm5, xmm0 - - movd r12, xmm5 - movd r10d, xmm5 - and r10d, 2097136 - - paddq xmm3, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r13+r11], xmm3 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - -CryptonightR_template_part2: - lea rcx, [r10+r11] - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor rsp, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov rax, r13 - mul r12 - add r15, rax - add rsp, rdx - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - movaps xmm3, xmm1 - movdqa xmm2, XMMWORD PTR [r9+r11] - movdqa xmm0, XMMWORD PTR [r10+r11] - pxor xmm1, xmm2 - pxor xmm5, xmm0 - pxor xmm5, xmm1 - paddq xmm3, xmm4 - paddq xmm2, xmm6 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqu XMMWORD PTR [r12+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm3 - - movdqa xmm7, xmm6 - mov QWORD PTR [rcx], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [rcx+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz CryptonightR_template_mainloop - -CryptonightR_template_part3: - movd rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -CryptonightR_template_end: - -ALIGN(64) -CryptonightR_template_double_part1: - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movd xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movd xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movd xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movd xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movd xmm0, rcx - mov r11d, 524288 - movd xmm10, rax - punpcklqdq xmm10, xmm0 - - movd xmm14, QWORD PTR [rsp+128] - movd xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -CryptonightR_template_double_mainloop: - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movd xmm0, r12 - mov ecx, ebx - movd xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movd xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm1 - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - pxor xmm6, xmm0 - movd rdx, xmm6 - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movd xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm1 - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movd rdi, xmm5 - movd rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movd xmm0, rsp - movd xmm1, rsi - movd xmm2, rdi - movd xmm11, rbp - movd xmm12, r15 - movd xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -CryptonightR_template_double_part2: - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r14, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r12, rax - - movd rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movd rsi, xmm1 - movd rdi, xmm2 - movd rbp, xmm11 - movd r15, xmm12 - movd rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movdqu xmm1, XMMWORD PTR [rcx+rsi] - pxor xmm6, xmm1 - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - pxor xmm6, xmm2 - paddq xmm2, xmm3 - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - pxor xmm6, xmm0 - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movd rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movd xmm0, rsp - movd xmm1, rbx - movd xmm2, rsi - movd xmm11, rdi - movd xmm12, rbp - movd xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movd xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -CryptonightR_template_double_part3: - - movd r15, xmm13 - - mov eax, edi - mov edx, ebp - shl rdx, 32 - or rax, rdx - xor r15, rax - - mov eax, ebx - mov edx, esi - shl rdx, 32 - or rax, rdx - xor r13, rax - - movd rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movd rbx, xmm1 - movd rsi, xmm2 - movd rdi, xmm11 - movd rbp, xmm12 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - mov rdi, rcx - mov r8, rax - movdqu xmm1, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm1 - xor ebp, 48 - paddq xmm1, xmm8 - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm2 - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - pxor xmm5, xmm0 - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movd rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz CryptonightR_template_double_mainloop - -CryptonightR_template_double_part4: - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -CryptonightR_template_double_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_soft_aes_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_soft_aes_template_win.inc deleted file mode 100644 index 6820903671..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_soft_aes_template_win.inc +++ /dev/null @@ -1,266 +0,0 @@ -PUBLIC CryptonightWOW_soft_aes_template_part1 -PUBLIC CryptonightWOW_soft_aes_template_mainloop -PUBLIC CryptonightWOW_soft_aes_template_part2 -PUBLIC CryptonightWOW_soft_aes_template_part3 -PUBLIC CryptonightWOW_soft_aes_template_end - -ALIGN(64) -CryptonightWOW_soft_aes_template_part1: - mov QWORD PTR [rsp+8], rcx - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 232 - - mov eax, [rcx+96] - mov ebx, [rcx+100] - mov esi, [rcx+104] - mov edx, [rcx+108] - mov [rsp+144], eax - mov [rsp+148], ebx - mov [rsp+152], esi - mov [rsp+156], edx - - mov rax, QWORD PTR [rcx+48] - mov r10, rcx - xor rax, QWORD PTR [rcx+16] - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r9, QWORD PTR [rcx+40] - xor r9, QWORD PTR [rcx+8] - movd xmm4, rax - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov r11, QWORD PTR [rcx+224] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r10+72] - mov rax, QWORD PTR [r10+80] - movd xmm0, rdx - xor rax, QWORD PTR [r10+64] - - movaps XMMWORD PTR [rsp+16], xmm6 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+48], xmm8 - movaps XMMWORD PTR [rsp+64], xmm9 - movaps XMMWORD PTR [rsp+80], xmm10 - movaps XMMWORD PTR [rsp+96], xmm11 - movaps XMMWORD PTR [rsp+112], xmm12 - movaps XMMWORD PTR [rsp+128], xmm13 - - movd xmm5, rax - - mov rax, r8 - punpcklqdq xmm4, xmm0 - and eax, 2097136 - movd xmm10, QWORD PTR [r10+96] - movd xmm0, rcx - mov rcx, QWORD PTR [r10+104] - xorps xmm9, xmm9 - mov QWORD PTR [rsp+328], rax - movd xmm12, r11 - mov QWORD PTR [rsp+320], r9 - punpcklqdq xmm5, xmm0 - movd xmm13, rcx - mov r12d, 524288 - - ALIGN(64) -CryptonightWOW_soft_aes_template_mainloop: - movd xmm11, r12d - mov r12, QWORD PTR [r10+272] - lea r13, QWORD PTR [rax+r11] - mov esi, DWORD PTR [r13] - movd xmm0, r9 - mov r10d, DWORD PTR [r13+4] - movd xmm7, r8 - mov ebp, DWORD PTR [r13+12] - mov r14d, DWORD PTR [r13+8] - mov rdx, QWORD PTR [rsp+328] - movzx ecx, sil - shr esi, 8 - punpcklqdq xmm7, xmm0 - mov r15d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - mov edi, DWORD PTR [r12+rcx*4] - movzx ecx, r14b - shr r14d, 8 - mov ebx, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - shr ebp, 8 - mov r9d, DWORD PTR [r12+rcx*4] - movzx ecx, r10b - shr r10d, 8 - xor r15d, DWORD PTR [r12+rcx*4+1024] - movzx ecx, r14b - shr r14d, 8 - mov eax, r14d - shr eax, 8 - xor edi, DWORD PTR [r12+rcx*4+1024] - add eax, 256 - movzx ecx, bpl - shr ebp, 8 - xor ebx, DWORD PTR [r12+rcx*4+1024] - movzx ecx, sil - shr esi, 8 - xor r9d, DWORD PTR [r12+rcx*4+1024] - add r12, 2048 - movzx ecx, r10b - shr r10d, 8 - add r10d, 256 - mov r11d, DWORD PTR [r12+rax*4] - xor r11d, DWORD PTR [r12+rcx*4] - xor r11d, r9d - movzx ecx, sil - mov r10d, DWORD PTR [r12+r10*4] - shr esi, 8 - add esi, 256 - xor r10d, DWORD PTR [r12+rcx*4] - movzx ecx, bpl - xor r10d, ebx - shr ebp, 8 - movd xmm1, r11d - add ebp, 256 - movd r11, xmm12 - mov r9d, DWORD PTR [r12+rcx*4] - xor r9d, DWORD PTR [r12+rsi*4] - mov eax, DWORD PTR [r12+rbp*4] - xor r9d, edi - movzx ecx, r14b - movd xmm0, r10d - movd xmm2, r9d - xor eax, DWORD PTR [r12+rcx*4] - mov rcx, rdx - xor eax, r15d - punpckldq xmm2, xmm1 - xor rcx, 16 - movd xmm6, eax - mov rax, rdx - punpckldq xmm6, xmm0 - xor rax, 32 - punpckldq xmm6, xmm2 - xor rdx, 48 - movdqu xmm2, XMMWORD PTR [rcx+r11] - pxor xmm6, xmm7 - paddq xmm2, xmm4 - movdqu xmm1, XMMWORD PTR [rax+r11] - movdqu xmm0, XMMWORD PTR [rdx+r11] - paddq xmm0, xmm5 - movdqu XMMWORD PTR [rcx+r11], xmm0 - movdqu XMMWORD PTR [rax+r11], xmm2 - movd rcx, xmm13 - paddq xmm1, xmm7 - movdqu XMMWORD PTR [rdx+r11], xmm1 - movd rdi, xmm6 - mov r10, rdi - and r10d, 2097136 - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [r13], xmm0 - - mov ebx, [rsp+144] - mov ebp, [rsp+152] - add ebx, [rsp+148] - add ebp, [rsp+156] - shl rbp, 32 - or rbx, rbp - - xor rbx, QWORD PTR [r10+r11] - lea r14, QWORD PTR [r10+r11] - mov rbp, QWORD PTR [r14+8] - - mov [rsp+160], rbx - mov [rsp+168], rdi - mov [rsp+176], rbp - mov [rsp+184], r10 - mov r10, rsp - - mov ebx, [rsp+144] - mov esi, [rsp+148] - mov edi, [rsp+152] - mov ebp, [rsp+156] - - movd esp, xmm7 - movaps xmm0, xmm7 - psrldq xmm0, 8 - movd r15d, xmm0 - movd eax, xmm4 - movd edx, xmm5 - -CryptonightWOW_soft_aes_template_part2: - mov rsp, r10 - mov [rsp+144], ebx - mov [rsp+148], esi - mov [rsp+152], edi - mov [rsp+156], ebp - - mov rbx, [rsp+160] - mov rdi, [rsp+168] - mov rbp, [rsp+176] - mov r10, [rsp+184] - - mov r9, r10 - xor r9, 16 - mov rcx, r10 - xor rcx, 32 - xor r10, 48 - mov rax, rbx - mul rdi - movdqu xmm2, XMMWORD PTR [r9+r11] - movdqu xmm1, XMMWORD PTR [rcx+r11] - paddq xmm1, xmm7 - movd xmm0, rax - movd xmm3, rdx - xor rax, QWORD PTR [r11+rcx+8] - xor rdx, QWORD PTR [rcx+r11] - punpcklqdq xmm3, xmm0 - add r8, rdx - movdqu xmm0, XMMWORD PTR [r10+r11] - pxor xmm2, xmm3 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [r9+r11], xmm0 - movdqa xmm5, xmm4 - mov r9, QWORD PTR [rsp+320] - movdqa xmm4, xmm6 - add r9, rax - movdqu XMMWORD PTR [rcx+r11], xmm2 - movdqu XMMWORD PTR [r10+r11], xmm1 - mov r10, QWORD PTR [rsp+304] - movd r12d, xmm11 - mov QWORD PTR [r14], r8 - xor r8, rbx - mov rax, r8 - mov QWORD PTR [r14+8], r9 - and eax, 2097136 - xor r9, rbp - mov QWORD PTR [rsp+320], r9 - mov QWORD PTR [rsp+328], rax - sub r12d, 1 - jne CryptonightWOW_soft_aes_template_mainloop - -CryptonightWOW_soft_aes_template_part3: - movaps xmm6, XMMWORD PTR [rsp+16] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+48] - movaps xmm9, XMMWORD PTR [rsp+64] - movaps xmm10, XMMWORD PTR [rsp+80] - movaps xmm11, XMMWORD PTR [rsp+96] - movaps xmm12, XMMWORD PTR [rsp+112] - movaps xmm13, XMMWORD PTR [rsp+128] - - add rsp, 232 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - ret -CryptonightWOW_soft_aes_template_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template.inc deleted file mode 100644 index 47fbc94f83..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template.inc +++ /dev/null @@ -1,486 +0,0 @@ -PUBLIC FN_PREFIX(CryptonightWOW_template_part1) -PUBLIC FN_PREFIX(CryptonightWOW_template_mainloop) -PUBLIC FN_PREFIX(CryptonightWOW_template_part2) -PUBLIC FN_PREFIX(CryptonightWOW_template_part3) -PUBLIC FN_PREFIX(CryptonightWOW_template_end) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part1) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_mainloop) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part2) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part3) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_part4) -PUBLIC FN_PREFIX(CryptonightWOW_template_double_end) - -ALIGN(64) -FN_PREFIX(CryptonightWOW_template_part1): - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movd xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movd xmm0, r12 - movd xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movd xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -FN_PREFIX(CryptonightWOW_template_mainloop): - movdqa xmm5, XMMWORD PTR [r9+r11] - movd xmm0, r15 - movd xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - movd r10d, xmm5 - and r10d, 2097136 - - mov r12d, r9d - mov eax, r9d - xor r9d, 48 - xor r12d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movdqu xmm2, XMMWORD PTR [r12+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - paddq xmm0, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r12+r11], xmm0 - movd r12, xmm5 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - -FN_PREFIX(CryptonightWOW_template_part2): - mov rax, r13 - mul r12 - movd xmm0, rax - movd xmm3, rdx - punpcklqdq xmm3, xmm0 - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - xor rdx, QWORD PTR [r12+r11] - xor rax, QWORD PTR [r11+r12+8] - movdqa xmm2, XMMWORD PTR [r9+r11] - pxor xmm3, xmm2 - paddq xmm7, XMMWORD PTR [r10+r11] - paddq xmm1, xmm4 - paddq xmm3, xmm6 - movdqu XMMWORD PTR [r9+r11], xmm7 - movdqu XMMWORD PTR [r12+r11], xmm3 - movdqu XMMWORD PTR [r10+r11], xmm1 - - movdqa xmm7, xmm6 - add r15, rax - add rsp, rdx - xor r10, 48 - mov QWORD PTR [r10+r11], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [r10+r11+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz FN_PREFIX(CryptonightWOW_template_mainloop) - -FN_PREFIX(CryptonightWOW_template_part3): - movd rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -FN_PREFIX(CryptonightWOW_template_end): - -ALIGN(64) -FN_PREFIX(CryptonightWOW_template_double_part1): - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movd xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movd xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movd xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movd xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movd xmm0, rcx - mov r11d, 524288 - movd xmm10, rax - punpcklqdq xmm10, xmm0 - - movd xmm14, QWORD PTR [rsp+128] - movd xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -FN_PREFIX(CryptonightWOW_template_double_mainloop): - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movd xmm0, r12 - mov ecx, ebx - movd xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movd rdx, xmm6 - movd xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movd xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movd rdi, xmm5 - movd rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movd xmm0, rsp - movd xmm1, rsi - movd xmm2, rdi - movd xmm11, rbp - movd xmm12, r15 - movd xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -FN_PREFIX(CryptonightWOW_template_double_part2): - - movd rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movd rsi, xmm1 - movd rdi, xmm2 - movd rbp, xmm11 - movd r15, xmm12 - movd rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movd xmm1, rdx - movd xmm0, r8 - punpcklqdq xmm1, xmm0 - pxor xmm1, XMMWORD PTR [rcx+rsi] - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - xor rdx, QWORD PTR [rsi+rcx] - paddq xmm2, xmm3 - xor r8, QWORD PTR [rsi+rcx+8] - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movd rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movd xmm0, rsp - movd xmm1, rbx - movd xmm2, rsi - movd xmm11, rdi - movd xmm12, rbp - movd xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movd xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -FN_PREFIX(CryptonightWOW_template_double_part3): - - movd rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movd rbx, xmm1 - movd rsi, xmm2 - movd rdi, xmm11 - movd rbp, xmm12 - movd r15, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - movd xmm1, rdx - movd xmm0, rax - punpcklqdq xmm1, xmm0 - mov rdi, rcx - mov r8, rax - pxor xmm1, XMMWORD PTR [rbp+rcx] - xor ebp, 48 - paddq xmm1, xmm8 - xor r8, QWORD PTR [rbp+rcx+8] - xor rdx, QWORD PTR [rbp+rcx] - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movd rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz FN_PREFIX(CryptonightWOW_template_double_mainloop) - -FN_PREFIX(CryptonightWOW_template_double_part4): - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -FN_PREFIX(CryptonightWOW_template_double_end): diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template_win.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template_win.inc deleted file mode 100644 index 9db2cf397f..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/CryptonightWOW_template_win.inc +++ /dev/null @@ -1,486 +0,0 @@ -PUBLIC CryptonightWOW_template_part1 -PUBLIC CryptonightWOW_template_mainloop -PUBLIC CryptonightWOW_template_part2 -PUBLIC CryptonightWOW_template_part3 -PUBLIC CryptonightWOW_template_end -PUBLIC CryptonightWOW_template_double_part1 -PUBLIC CryptonightWOW_template_double_mainloop -PUBLIC CryptonightWOW_template_double_part2 -PUBLIC CryptonightWOW_template_double_part3 -PUBLIC CryptonightWOW_template_double_part4 -PUBLIC CryptonightWOW_template_double_end - -ALIGN(64) -CryptonightWOW_template_part1: - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push r10 - push r11 - push r12 - push r13 - push r14 - push r15 - push rdi - sub rsp, 64 - mov r12, rcx - mov r8, QWORD PTR [r12+32] - mov rdx, r12 - xor r8, QWORD PTR [r12] - mov r15, QWORD PTR [r12+40] - mov r9, r8 - xor r15, QWORD PTR [r12+8] - mov r11, QWORD PTR [r12+224] - mov r12, QWORD PTR [r12+56] - xor r12, QWORD PTR [rdx+24] - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm0, r12 - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - movaps XMMWORD PTR [rsp], xmm9 - mov r12, QWORD PTR [rdx+88] - xor r12, QWORD PTR [rdx+72] - movd xmm6, rax - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm6, xmm0 - and r9d, 2097136 - movd xmm0, r12 - movd xmm7, rax - punpcklqdq xmm7, xmm0 - mov r10d, r9d - movd xmm9, rsp - mov rsp, r8 - mov r8d, 524288 - - mov ebx, [rdx+96] - mov esi, [rdx+100] - mov edi, [rdx+104] - mov ebp, [rdx+108] - - ALIGN(64) -CryptonightWOW_template_mainloop: - movdqa xmm5, XMMWORD PTR [r9+r11] - movd xmm0, r15 - movd xmm4, rsp - punpcklqdq xmm4, xmm0 - lea rdx, QWORD PTR [r9+r11] - - aesenc xmm5, xmm4 - movd r10d, xmm5 - and r10d, 2097136 - - mov r12d, r9d - mov eax, r9d - xor r9d, 48 - xor r12d, 16 - xor eax, 32 - movdqu xmm0, XMMWORD PTR [r9+r11] - movdqu xmm2, XMMWORD PTR [r12+r11] - movdqu xmm1, XMMWORD PTR [rax+r11] - paddq xmm0, xmm7 - paddq xmm2, xmm6 - paddq xmm1, xmm4 - movdqu XMMWORD PTR [r12+r11], xmm0 - movd r12, xmm5 - movdqu XMMWORD PTR [rax+r11], xmm2 - movdqu XMMWORD PTR [r9+r11], xmm1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [rdx], xmm0 - - lea r13d, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or r13, rdx - - xor r13, QWORD PTR [r10+r11] - mov r14, QWORD PTR [r10+r11+8] - - movd eax, xmm6 - movd edx, xmm7 - pextrd r9d, xmm7, 2 - -CryptonightWOW_template_part2: - mov rax, r13 - mul r12 - movd xmm0, rax - movd xmm3, rdx - punpcklqdq xmm3, xmm0 - - mov r9d, r10d - mov r12d, r10d - xor r9d, 16 - xor r12d, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [r12+r11] - xor rdx, QWORD PTR [r12+r11] - xor rax, QWORD PTR [r11+r12+8] - movdqa xmm2, XMMWORD PTR [r9+r11] - pxor xmm3, xmm2 - paddq xmm7, XMMWORD PTR [r10+r11] - paddq xmm1, xmm4 - paddq xmm3, xmm6 - movdqu XMMWORD PTR [r9+r11], xmm7 - movdqu XMMWORD PTR [r12+r11], xmm3 - movdqu XMMWORD PTR [r10+r11], xmm1 - - movdqa xmm7, xmm6 - add r15, rax - add rsp, rdx - xor r10, 48 - mov QWORD PTR [r10+r11], rsp - xor rsp, r13 - mov r9d, esp - mov QWORD PTR [r10+r11+8], r15 - and r9d, 2097136 - xor r15, r14 - movdqa xmm6, xmm5 - dec r8d - jnz CryptonightWOW_template_mainloop - -CryptonightWOW_template_part3: - movd rsp, xmm9 - - mov rbx, QWORD PTR [rsp+136] - mov rbp, QWORD PTR [rsp+144] - mov rsi, QWORD PTR [rsp+152] - movaps xmm6, XMMWORD PTR [rsp+48] - movaps xmm7, XMMWORD PTR [rsp+32] - movaps xmm8, XMMWORD PTR [rsp+16] - movaps xmm9, XMMWORD PTR [rsp] - add rsp, 64 - pop rdi - pop r15 - pop r14 - pop r13 - pop r12 - pop r11 - pop r10 - ret 0 -CryptonightWOW_template_end: - -ALIGN(64) -CryptonightWOW_template_double_part1: - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 320 - mov r14, QWORD PTR [rcx+32] - mov r8, rcx - xor r14, QWORD PTR [rcx] - mov r12, QWORD PTR [rcx+40] - mov ebx, r14d - mov rsi, QWORD PTR [rcx+224] - and ebx, 2097136 - xor r12, QWORD PTR [rcx+8] - mov rcx, QWORD PTR [rcx+56] - xor rcx, QWORD PTR [r8+24] - mov rax, QWORD PTR [r8+48] - xor rax, QWORD PTR [r8+16] - mov r15, QWORD PTR [rdx+32] - xor r15, QWORD PTR [rdx] - movd xmm0, rcx - mov rcx, QWORD PTR [r8+88] - xor rcx, QWORD PTR [r8+72] - mov r13, QWORD PTR [rdx+40] - mov rdi, QWORD PTR [rdx+224] - xor r13, QWORD PTR [rdx+8] - movaps XMMWORD PTR [rsp+160], xmm6 - movaps XMMWORD PTR [rsp+176], xmm7 - movaps XMMWORD PTR [rsp+192], xmm8 - movaps XMMWORD PTR [rsp+208], xmm9 - movaps XMMWORD PTR [rsp+224], xmm10 - movaps XMMWORD PTR [rsp+240], xmm11 - movaps XMMWORD PTR [rsp+256], xmm12 - movaps XMMWORD PTR [rsp+272], xmm13 - movaps XMMWORD PTR [rsp+288], xmm14 - movaps XMMWORD PTR [rsp+304], xmm15 - movd xmm7, rax - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - - movaps xmm1, XMMWORD PTR [rdx+96] - movaps xmm2, XMMWORD PTR [r8+96] - movaps XMMWORD PTR [rsp], xmm1 - movaps XMMWORD PTR [rsp+16], xmm2 - - mov r8d, r15d - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+56] - xor rcx, QWORD PTR [rdx+24] - movd xmm9, rax - mov QWORD PTR [rsp+128], rsi - mov rax, QWORD PTR [rdx+48] - xor rax, QWORD PTR [rdx+16] - punpcklqdq xmm9, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [rdx+88] - xor rcx, QWORD PTR [rdx+72] - movd xmm8, rax - mov QWORD PTR [rsp+136], rdi - mov rax, QWORD PTR [rdx+80] - xor rax, QWORD PTR [rdx+64] - punpcklqdq xmm8, xmm0 - and r8d, 2097136 - movd xmm0, rcx - mov r11d, 524288 - movd xmm10, rax - punpcklqdq xmm10, xmm0 - - movd xmm14, QWORD PTR [rsp+128] - movd xmm15, QWORD PTR [rsp+136] - - ALIGN(64) -CryptonightWOW_template_double_mainloop: - movdqu xmm6, XMMWORD PTR [rbx+rsi] - movd xmm0, r12 - mov ecx, ebx - movd xmm3, r14 - punpcklqdq xmm3, xmm0 - xor ebx, 16 - aesenc xmm6, xmm3 - movd rdx, xmm6 - movd xmm4, r15 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - xor ebx, 48 - paddq xmm0, xmm7 - movdqu xmm1, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm0 - paddq xmm1, xmm3 - xor ebx, 16 - mov eax, ebx - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbx+rsi] - movdqu XMMWORD PTR [rbx+rsi], xmm1 - paddq xmm0, xmm9 - movdqu XMMWORD PTR [rax+rsi], xmm0 - movdqa xmm0, xmm6 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [rcx+rsi], xmm0 - mov esi, edx - movdqu xmm5, XMMWORD PTR [r8+rdi] - and esi, 2097136 - mov ecx, r8d - movd xmm0, r13 - punpcklqdq xmm4, xmm0 - xor r8d, 16 - aesenc xmm5, xmm4 - movdqu xmm0, XMMWORD PTR [r8+rdi] - xor r8d, 48 - paddq xmm0, xmm8 - movdqu xmm1, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm0 - paddq xmm1, xmm4 - xor r8d, 16 - mov eax, r8d - xor rax, 32 - movdqu xmm0, XMMWORD PTR [r8+rdi] - movdqu XMMWORD PTR [r8+rdi], xmm1 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rdi], xmm0 - movdqa xmm0, xmm5 - pxor xmm0, xmm8 - movdqu XMMWORD PTR [rcx+rdi], xmm0 - movd rdi, xmm5 - movd rcx, xmm14 - mov ebp, edi - mov r8, QWORD PTR [rcx+rsi] - mov r10, QWORD PTR [rcx+rsi+8] - lea r9, QWORD PTR [rcx+rsi] - xor esi, 16 - - movd xmm0, rsp - movd xmm1, rsi - movd xmm2, rdi - movd xmm11, rbp - movd xmm12, r15 - movd xmm13, rdx - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp+16] - mov esi, DWORD PTR [rsp+20] - mov edi, DWORD PTR [rsp+24] - mov ebp, DWORD PTR [rsp+28] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - xor r8, rax - - movd esp, xmm3 - pextrd r15d, xmm3, 2 - movd eax, xmm7 - movd edx, xmm9 - pextrd r9d, xmm9, 2 - -CryptonightWOW_template_double_part2: - - movd rsp, xmm0 - mov DWORD PTR [rsp+16], ebx - mov DWORD PTR [rsp+20], esi - mov DWORD PTR [rsp+24], edi - mov DWORD PTR [rsp+28], ebp - - movd rsi, xmm1 - movd rdi, xmm2 - movd rbp, xmm11 - movd r15, xmm12 - movd rdx, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rbx, r8 - mov rax, r8 - mul rdx - and ebp, 2097136 - mov r8, rax - movd xmm1, rdx - movd xmm0, r8 - punpcklqdq xmm1, xmm0 - pxor xmm1, XMMWORD PTR [rcx+rsi] - xor esi, 48 - paddq xmm1, xmm7 - movdqu xmm2, XMMWORD PTR [rsi+rcx] - xor rdx, QWORD PTR [rsi+rcx] - paddq xmm2, xmm3 - xor r8, QWORD PTR [rsi+rcx+8] - movdqu XMMWORD PTR [rsi+rcx], xmm1 - xor esi, 16 - mov eax, esi - mov rsi, rcx - movdqu xmm0, XMMWORD PTR [rax+rcx] - movdqu XMMWORD PTR [rax+rcx], xmm2 - paddq xmm0, xmm9 - add r12, r8 - xor rax, 32 - add r14, rdx - movdqa xmm9, xmm7 - movdqa xmm7, xmm6 - movdqu XMMWORD PTR [rax+rcx], xmm0 - mov QWORD PTR [r9+8], r12 - xor r12, r10 - mov QWORD PTR [r9], r14 - movd rcx, xmm15 - xor r14, rbx - mov r10d, ebp - mov ebx, r14d - xor ebp, 16 - and ebx, 2097136 - mov r8, QWORD PTR [r10+rcx] - mov r9, QWORD PTR [r10+rcx+8] - - movd xmm0, rsp - movd xmm1, rbx - movd xmm2, rsi - movd xmm11, rdi - movd xmm12, rbp - movd xmm13, r15 - mov [rsp+104], rcx - mov [rsp+112], r9 - - mov ebx, DWORD PTR [rsp] - mov esi, DWORD PTR [rsp+4] - mov edi, DWORD PTR [rsp+8] - mov ebp, DWORD PTR [rsp+12] - - lea eax, [ebx+esi] - lea edx, [edi+ebp] - shl rdx, 32 - or rax, rdx - - xor r8, rax - movd xmm3, r8 - - movd esp, xmm4 - pextrd r15d, xmm4, 2 - movd eax, xmm8 - movd edx, xmm10 - pextrd r9d, xmm10, 2 - -CryptonightWOW_template_double_part3: - - movd rsp, xmm0 - mov DWORD PTR [rsp], ebx - mov DWORD PTR [rsp+4], esi - mov DWORD PTR [rsp+8], edi - mov DWORD PTR [rsp+12], ebp - - movd rbx, xmm1 - movd rsi, xmm2 - movd rdi, xmm11 - movd rbp, xmm12 - movd r15, xmm13 - mov rcx, [rsp+104] - mov r9, [rsp+112] - - mov rax, r8 - mul rdi - movd xmm1, rdx - movd xmm0, rax - punpcklqdq xmm1, xmm0 - mov rdi, rcx - mov r8, rax - pxor xmm1, XMMWORD PTR [rbp+rcx] - xor ebp, 48 - paddq xmm1, xmm8 - xor r8, QWORD PTR [rbp+rcx+8] - xor rdx, QWORD PTR [rbp+rcx] - add r13, r8 - movdqu xmm2, XMMWORD PTR [rbp+rcx] - add r15, rdx - movdqu XMMWORD PTR [rbp+rcx], xmm1 - paddq xmm2, xmm4 - xor ebp, 16 - mov eax, ebp - xor rax, 32 - movdqu xmm0, XMMWORD PTR [rbp+rcx] - movdqu XMMWORD PTR [rbp+rcx], xmm2 - paddq xmm0, xmm10 - movdqu XMMWORD PTR [rax+rcx], xmm0 - movd rax, xmm3 - movdqa xmm10, xmm8 - mov QWORD PTR [r10+rcx], r15 - movdqa xmm8, xmm5 - xor r15, rax - mov QWORD PTR [r10+rcx+8], r13 - mov r8d, r15d - xor r13, r9 - and r8d, 2097136 - dec r11d - jnz CryptonightWOW_template_double_mainloop - -CryptonightWOW_template_double_part4: - - mov rbx, QWORD PTR [rsp+400] - movaps xmm6, XMMWORD PTR [rsp+160] - movaps xmm7, XMMWORD PTR [rsp+176] - movaps xmm8, XMMWORD PTR [rsp+192] - movaps xmm9, XMMWORD PTR [rsp+208] - movaps xmm10, XMMWORD PTR [rsp+224] - movaps xmm11, XMMWORD PTR [rsp+240] - movaps xmm12, XMMWORD PTR [rsp+256] - movaps xmm13, XMMWORD PTR [rsp+272] - movaps xmm14, XMMWORD PTR [rsp+288] - movaps xmm15, XMMWORD PTR [rsp+304] - add rsp, 320 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - ret 0 -CryptonightWOW_template_double_end: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_double_main_loop_sandybridge.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_double_main_loop_sandybridge.inc deleted file mode 100644 index 05af939347..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_double_main_loop_sandybridge.inc +++ /dev/null @@ -1,410 +0,0 @@ - mov rax, rsp - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 184 - - stmxcsr DWORD PTR [rsp+272] - mov DWORD PTR [rsp+276], 24448 - ldmxcsr DWORD PTR [rsp+276] - - mov r13, QWORD PTR [rcx+224] - mov r9, rdx - mov r10, QWORD PTR [rcx+32] - mov r8, rcx - xor r10, QWORD PTR [rcx] - mov r14d, 524288 - mov r11, QWORD PTR [rcx+40] - xor r11, QWORD PTR [rcx+8] - mov rsi, QWORD PTR [rdx+224] - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov rdi, QWORD PTR [r9+32] - xor rdi, QWORD PTR [r9] - mov rbp, QWORD PTR [r9+40] - xor rbp, QWORD PTR [r9+8] - movd xmm0, rdx - movaps XMMWORD PTR [rax-88], xmm6 - movaps XMMWORD PTR [rax-104], xmm7 - movaps XMMWORD PTR [rax-120], xmm8 - movaps XMMWORD PTR [rsp+112], xmm9 - movaps XMMWORD PTR [rsp+96], xmm10 - movaps XMMWORD PTR [rsp+80], xmm11 - movaps XMMWORD PTR [rsp+64], xmm12 - movaps XMMWORD PTR [rsp+48], xmm13 - movaps XMMWORD PTR [rsp+32], xmm14 - movaps XMMWORD PTR [rsp+16], xmm15 - mov rdx, r10 - movd xmm4, QWORD PTR [r8+96] - and edx, 2097136 - mov rax, QWORD PTR [rcx+48] - xorps xmm13, xmm13 - xor rax, QWORD PTR [rcx+16] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r8+72] - movd xmm5, QWORD PTR [r8+104] - movd xmm7, rax - - mov eax, 1 - shl rax, 52 - movd xmm14, rax - punpcklqdq xmm14, xmm14 - - mov eax, 1023 - shl rax, 52 - movd xmm12, rax - punpcklqdq xmm12, xmm12 - - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [r9+56] - xor rcx, QWORD PTR [r9+24] - movd xmm3, rax - mov rax, QWORD PTR [r9+48] - xor rax, QWORD PTR [r9+16] - punpcklqdq xmm3, xmm0 - movd xmm0, rcx - mov QWORD PTR [rsp], r13 - mov rcx, QWORD PTR [r9+88] - xor rcx, QWORD PTR [r9+72] - movd xmm6, rax - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - punpcklqdq xmm6, xmm0 - movd xmm0, rcx - mov QWORD PTR [rsp+256], r10 - mov rcx, rdi - mov QWORD PTR [rsp+264], r11 - movd xmm8, rax - and ecx, 2097136 - punpcklqdq xmm8, xmm0 - movd xmm0, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movd xmm0, QWORD PTR [r9+104] - lea r8, QWORD PTR [rcx+rsi] - movdqu xmm11, XMMWORD PTR [r8] - punpcklqdq xmm5, xmm0 - lea r9, QWORD PTR [rdx+r13] - movdqu xmm15, XMMWORD PTR [r9] - - ALIGN(64) -main_loop_double_sandybridge: - movdqu xmm9, xmm15 - mov eax, edx - mov ebx, edx - xor eax, 16 - xor ebx, 32 - xor edx, 48 - - movd xmm0, r11 - movd xmm2, r10 - punpcklqdq xmm2, xmm0 - aesenc xmm9, xmm2 - - movdqu xmm0, XMMWORD PTR [rax+r13] - movdqu xmm1, XMMWORD PTR [rbx+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [rbx+r13], xmm0 - movdqu xmm0, XMMWORD PTR [rdx+r13] - movdqu XMMWORD PTR [rdx+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [rax+r13], xmm0 - - movd r11, xmm9 - mov edx, r11d - and edx, 2097136 - movdqa xmm0, xmm9 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [r9], xmm0 - - lea rbx, QWORD PTR [rdx+r13] - mov r10, QWORD PTR [rdx+r13] - - movdqu xmm10, xmm11 - movd xmm0, rbp - movd xmm11, rdi - punpcklqdq xmm11, xmm0 - aesenc xmm10, xmm11 - - mov eax, ecx - mov r12d, ecx - xor eax, 16 - xor r12d, 32 - xor ecx, 48 - - movdqu xmm0, XMMWORD PTR [rax+rsi] - paddq xmm0, xmm6 - movdqu xmm1, XMMWORD PTR [r12+rsi] - movdqu XMMWORD PTR [r12+rsi], xmm0 - paddq xmm1, xmm11 - movdqu xmm0, XMMWORD PTR [rcx+rsi] - movdqu XMMWORD PTR [rcx+rsi], xmm1 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [rax+rsi], xmm0 - - movd rcx, xmm10 - and ecx, 2097136 - - movdqa xmm0, xmm10 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [r8], xmm0 - mov r12, QWORD PTR [rcx+rsi] - - mov r9, QWORD PTR [rbx+8] - - xor edx, 16 - mov r8d, edx - mov r15d, edx - - movd rdx, xmm5 - shl rdx, 32 - movd rax, xmm4 - xor rdx, rax - xor r10, rdx - mov rax, r10 - mul r11 - mov r11d, r8d - xor r11d, 48 - movd xmm0, rdx - xor rdx, [r11+r13] - movd xmm1, rax - xor rax, [r11+r13+8] - punpcklqdq xmm0, xmm1 - - pxor xmm0, XMMWORD PTR [r8+r13] - xor r8d, 32 - movdqu xmm1, XMMWORD PTR [r11+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [r11+r13], xmm0 - movdqu xmm0, XMMWORD PTR [r8+r13] - movdqu XMMWORD PTR [r8+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [r15+r13], xmm0 - - mov r11, QWORD PTR [rsp+256] - add r11, rdx - mov rdx, QWORD PTR [rsp+264] - add rdx, rax - mov QWORD PTR [rbx], r11 - xor r11, r10 - mov QWORD PTR [rbx+8], rdx - xor rdx, r9 - mov QWORD PTR [rsp+256], r11 - and r11d, 2097136 - mov QWORD PTR [rsp+264], rdx - mov QWORD PTR [rsp+8], r11 - lea r15, QWORD PTR [r11+r13] - movdqu xmm15, XMMWORD PTR [r11+r13] - lea r13, QWORD PTR [rsi+rcx] - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movaps xmm2, xmm13 - movd r10, xmm0 - psllq xmm5, 1 - shl r10, 32 - movdqa xmm0, xmm9 - psrldq xmm0, 8 - movdqa xmm1, xmm10 - movd r11, xmm0 - psrldq xmm1, 8 - movd r8, xmm1 - psrldq xmm4, 8 - movaps xmm0, xmm13 - movd rax, xmm4 - xor r10, rax - movaps xmm1, xmm13 - xor r10, r12 - lea rax, QWORD PTR [r11+1] - shr rax, 1 - movdqa xmm3, xmm9 - punpcklqdq xmm3, xmm10 - paddq xmm5, xmm3 - movd rdx, xmm5 - psrldq xmm5, 8 - cvtsi2sd xmm2, rax - or edx, -2147483647 - lea rax, QWORD PTR [r8+1] - shr rax, 1 - movd r9, xmm5 - cvtsi2sd xmm0, rax - or r9d, -2147483647 - cvtsi2sd xmm1, rdx - unpcklpd xmm2, xmm0 - movaps xmm0, xmm13 - cvtsi2sd xmm0, r9 - unpcklpd xmm1, xmm0 - divpd xmm2, xmm1 - paddq xmm2, xmm14 - cvttsd2si rax, xmm2 - psrldq xmm2, 8 - mov rbx, rax - imul rax, rdx - sub r11, rax - js div_fix_1_sandybridge -div_fix_1_ret_sandybridge: - - cvttsd2si rdx, xmm2 - mov rax, rdx - imul rax, r9 - movd xmm2, r11d - movd xmm4, ebx - sub r8, rax - js div_fix_2_sandybridge -div_fix_2_ret_sandybridge: - - movd xmm1, r8d - movd xmm0, edx - punpckldq xmm2, xmm1 - punpckldq xmm4, xmm0 - punpckldq xmm4, xmm2 - paddq xmm3, xmm4 - movdqa xmm0, xmm3 - psrlq xmm0, 12 - paddq xmm0, xmm12 - sqrtpd xmm1, xmm0 - movd r9, xmm1 - movdqa xmm5, xmm1 - psrlq xmm5, 19 - test r9, 524287 - je sqrt_fix_1_sandybridge -sqrt_fix_1_ret_sandybridge: - - movd r9, xmm10 - psrldq xmm1, 8 - movd r8, xmm1 - test r8, 524287 - je sqrt_fix_2_sandybridge -sqrt_fix_2_ret_sandybridge: - - mov r12d, ecx - mov r8d, ecx - xor r12d, 16 - xor r8d, 32 - xor ecx, 48 - mov rax, r10 - mul r9 - movd xmm0, rax - movd xmm3, rdx - punpcklqdq xmm3, xmm0 - - movdqu xmm0, XMMWORD PTR [r12+rsi] - pxor xmm0, xmm3 - movdqu xmm1, XMMWORD PTR [r8+rsi] - xor rdx, [r8+rsi] - xor rax, [r8+rsi+8] - movdqu xmm3, XMMWORD PTR [rcx+rsi] - paddq xmm0, xmm6 - paddq xmm1, xmm11 - paddq xmm3, xmm8 - movdqu XMMWORD PTR [r8+rsi], xmm0 - movdqu XMMWORD PTR [rcx+rsi], xmm1 - movdqu XMMWORD PTR [r12+rsi], xmm3 - - add rdi, rdx - mov QWORD PTR [r13], rdi - xor rdi, r10 - mov ecx, edi - and ecx, 2097136 - lea r8, QWORD PTR [rcx+rsi] - - mov rdx, QWORD PTR [r13+8] - add rbp, rax - mov QWORD PTR [r13+8], rbp - movdqu xmm11, XMMWORD PTR [rcx+rsi] - xor rbp, rdx - mov r13, QWORD PTR [rsp] - movdqa xmm3, xmm7 - mov rdx, QWORD PTR [rsp+8] - movdqa xmm8, xmm6 - mov r10, QWORD PTR [rsp+256] - movdqa xmm7, xmm9 - mov r11, QWORD PTR [rsp+264] - movdqa xmm6, xmm10 - mov r9, r15 - dec r14d - jne main_loop_double_sandybridge - - ldmxcsr DWORD PTR [rsp+272] - movaps xmm13, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+184] - movaps xmm6, XMMWORD PTR [r11-24] - movaps xmm7, XMMWORD PTR [r11-40] - movaps xmm8, XMMWORD PTR [r11-56] - movaps xmm9, XMMWORD PTR [r11-72] - movaps xmm10, XMMWORD PTR [r11-88] - movaps xmm11, XMMWORD PTR [r11-104] - movaps xmm12, XMMWORD PTR [r11-120] - movaps xmm14, XMMWORD PTR [rsp+32] - movaps xmm15, XMMWORD PTR [rsp+16] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - jmp cnv2_double_mainloop_asm_sandybridge_endp - -div_fix_1_sandybridge: - dec rbx - add r11, rdx - jmp div_fix_1_ret_sandybridge - -div_fix_2_sandybridge: - dec rdx - add r8, r9 - jmp div_fix_2_ret_sandybridge - -sqrt_fix_1_sandybridge: - movd r8, xmm3 - movdqa xmm0, xmm5 - psrldq xmm0, 8 - dec r9 - mov r11d, -1022 - shl r11, 32 - mov rax, r9 - shr r9, 19 - shr rax, 20 - mov rdx, r9 - sub rdx, rax - lea rdx, [rdx+r11+1] - add rax, r11 - imul rdx, rax - sub rdx, r8 - adc r9, 0 - movd xmm5, r9 - punpcklqdq xmm5, xmm0 - jmp sqrt_fix_1_ret_sandybridge - -sqrt_fix_2_sandybridge: - psrldq xmm3, 8 - movd r11, xmm3 - dec r8 - mov ebx, -1022 - shl rbx, 32 - mov rax, r8 - shr r8, 19 - shr rax, 20 - mov rdx, r8 - sub rdx, rax - lea rdx, [rdx+rbx+1] - add rax, rbx - imul rdx, rax - sub rdx, r11 - adc r8, 0 - movd xmm0, r8 - punpcklqdq xmm5, xmm0 - jmp sqrt_fix_2_ret_sandybridge - -cnv2_double_mainloop_asm_sandybridge_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_bulldozer.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_bulldozer.inc deleted file mode 100644 index 03a36f48dc..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_bulldozer.inc +++ /dev/null @@ -1,180 +0,0 @@ - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 64 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov ebp, 524288 - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movd xmm3, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movd xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - mov rdi, QWORD PTR [r9+104] - and r10d, 2097136 - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm4, rax - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - xorps xmm8, xmm8 - mov ax, 1023 - shl rax, 52 - movd xmm7, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm3, xmm0 - movd xmm0, rcx - punpcklqdq xmm4, xmm0 - - ALIGN(64) -cnv2_main_loop_bulldozer: - movdqa xmm5, XMMWORD PTR [r10+rbx] - movd xmm6, r8 - pinsrq xmm6, r11, 1 - lea rdx, QWORD PTR [r10+rbx] - lea r9, QWORD PTR [rdi+rdi] - shl rdi, 32 - - mov ecx, r10d - mov eax, r10d - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - aesenc xmm5, xmm6 - movdqa xmm2, XMMWORD PTR [rcx+rbx] - movdqa xmm1, XMMWORD PTR [rax+rbx] - movdqa xmm0, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - paddq xmm0, xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm0 - movdqa XMMWORD PTR [rax+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movaps xmm1, xmm8 - mov rsi, r15 - xor rsi, rdi - - mov edi, 1023 - shl rdi, 52 - - movd r14, xmm5 - pextrq rax, xmm5, 1 - - movdqa xmm0, xmm5 - pxor xmm0, xmm3 - mov r10, r14 - and r10d, 2097136 - movdqa XMMWORD PTR [rdx], xmm0 - xor rsi, QWORD PTR [r10+rbx] - lea r12, QWORD PTR [r10+rbx] - mov r13, QWORD PTR [r10+rbx+8] - - add r9d, r14d - or r9d, -2147483647 - xor edx, edx - div r9 - mov eax, eax - shl rdx, 32 - lea r15, [rax+rdx] - lea rax, [r14+r15] - shr rax, 12 - add rax, rdi - movd xmm0, rax - sqrtsd xmm1, xmm0 - movd rdi, xmm1 - test rdi, 524287 - je sqrt_fixup_bulldozer - shr rdi, 19 - -sqrt_fixup_bulldozer_ret: - mov rax, rsi - mul r14 - movd xmm1, rax - movd xmm0, rdx - punpcklqdq xmm0, xmm1 - - mov r9d, r10d - mov ecx, r10d - xor r9d, 16 - xor ecx, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [rcx+rbx] - xor rdx, [rcx+rbx] - xor rax, [rcx+rbx+8] - movdqa xmm2, XMMWORD PTR [r9+rbx] - pxor xmm2, xmm0 - paddq xmm4, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - movdqa XMMWORD PTR [r9+rbx], xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movdqa xmm4, xmm3 - add r8, rdx - add r11, rax - mov QWORD PTR [r12], r8 - xor r8, rsi - mov QWORD PTR [r12+8], r11 - mov r10, r8 - xor r11, r13 - and r10d, 2097136 - movdqa xmm3, xmm5 - dec ebp - jne cnv2_main_loop_bulldozer - - ldmxcsr DWORD PTR [rsp] - movaps xmm6, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+64] - mov rbx, QWORD PTR [r11+56] - mov rbp, QWORD PTR [r11+64] - mov rsi, QWORD PTR [r11+72] - movaps xmm8, XMMWORD PTR [r11-48] - movaps xmm7, XMMWORD PTR [rsp+32] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - jmp cnv2_main_loop_bulldozer_endp - -sqrt_fixup_bulldozer: - movd r9, xmm5 - add r9, r15 - dec rdi - mov edx, -1022 - shl rdx, 32 - mov rax, rdi - shr rdi, 19 - shr rax, 20 - mov rcx, rdi - sub rcx, rax - lea rcx, [rcx+rdx+1] - add rax, rdx - imul rcx, rax - sub rcx, r9 - adc rdi, 0 - jmp sqrt_fixup_bulldozer_ret - -cnv2_main_loop_bulldozer_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ivybridge.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ivybridge.inc deleted file mode 100644 index 77e28f8013..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ivybridge.inc +++ /dev/null @@ -1,186 +0,0 @@ - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 80 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov esi, 524288 - mov r8, QWORD PTR [rcx+32] - mov r13d, -2147483647 - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movd xmm4, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movd xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - movd xmm3, QWORD PTR [r9+104] - movaps XMMWORD PTR [rsp+64], xmm6 - movaps XMMWORD PTR [rsp+48], xmm7 - movaps XMMWORD PTR [rsp+32], xmm8 - and r10d, 2097136 - movd xmm5, rax - - xor eax, eax - mov QWORD PTR [rsp+16], rax - - mov ax, 1023 - shl rax, 52 - movd xmm8, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movd xmm0, rcx - punpcklqdq xmm5, xmm0 - movdqu xmm6, XMMWORD PTR [r10+rbx] - - ALIGN(64) -main_loop_ivybridge: - lea rdx, QWORD PTR [r10+rbx] - mov ecx, r10d - mov eax, r10d - mov rdi, r15 - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - movd xmm0, r11 - movd xmm7, r8 - punpcklqdq xmm7, xmm0 - aesenc xmm6, xmm7 - movd rbp, xmm6 - mov r9, rbp - and r9d, 2097136 - movdqu xmm2, XMMWORD PTR [rcx+rbx] - movdqu xmm1, XMMWORD PTR [rax+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm1, xmm7 - paddq xmm0, xmm5 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [rax+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - mov r10, r9 - xor r10d, 32 - movd rcx, xmm3 - mov rax, rcx - shl rax, 32 - xor rdi, rax - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [rdx], xmm0 - xor rdi, QWORD PTR [r9+rbx] - lea r14, QWORD PTR [r9+rbx] - mov r12, QWORD PTR [r14+8] - xor edx, edx - lea r9d, DWORD PTR [ecx+ecx] - add r9d, ebp - movdqa xmm0, xmm6 - psrldq xmm0, 8 - or r9d, r13d - movd rax, xmm0 - div r9 - xorps xmm3, xmm3 - mov eax, eax - shl rdx, 32 - add rdx, rax - lea r9, QWORD PTR [rdx+rbp] - mov r15, rdx - mov rax, r9 - shr rax, 12 - movd xmm0, rax - paddq xmm0, xmm8 - sqrtsd xmm3, xmm0 - psubq xmm3, XMMWORD PTR [rsp+16] - movd rdx, xmm3 - test edx, 524287 - je sqrt_fixup_ivybridge - psrlq xmm3, 19 -sqrt_fixup_ivybridge_ret: - - mov ecx, r10d - mov rax, rdi - mul rbp - movd xmm2, rdx - xor rdx, [rcx+rbx] - add r8, rdx - mov QWORD PTR [r14], r8 - xor r8, rdi - mov edi, r8d - and edi, 2097136 - movd xmm0, rax - xor rax, [rcx+rbx+8] - add r11, rax - mov QWORD PTR [r14+8], r11 - punpcklqdq xmm2, xmm0 - - mov r9d, r10d - xor r9d, 48 - xor r10d, 16 - pxor xmm2, XMMWORD PTR [r9+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm5 - movdqu xmm1, XMMWORD PTR [rcx+rbx] - paddq xmm2, xmm4 - paddq xmm1, xmm7 - movdqa xmm5, xmm4 - movdqu XMMWORD PTR [r9+rbx], xmm0 - movdqa xmm4, xmm6 - movdqu XMMWORD PTR [rcx+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - movdqu xmm6, [rdi+rbx] - mov r10d, edi - xor r11, r12 - dec rsi - jne main_loop_ivybridge - - ldmxcsr DWORD PTR [rsp] - mov rbx, QWORD PTR [rsp+160] - movaps xmm6, XMMWORD PTR [rsp+64] - movaps xmm7, XMMWORD PTR [rsp+48] - movaps xmm8, XMMWORD PTR [rsp+32] - add rsp, 80 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - jmp cnv2_main_loop_ivybridge_endp - -sqrt_fixup_ivybridge: - dec rdx - mov r13d, -1022 - shl r13, 32 - mov rax, rdx - shr rdx, 19 - shr rax, 20 - mov rcx, rdx - sub rcx, rax - add rax, r13 - not r13 - sub rcx, r13 - mov r13d, -2147483647 - imul rcx, rax - sub rcx, r9 - adc rdx, 0 - movd xmm3, rdx - jmp sqrt_fixup_ivybridge_ret - -cnv2_main_loop_ivybridge_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ryzen.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ryzen.inc deleted file mode 100644 index 7e5c127f81..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_main_loop_ryzen.inc +++ /dev/null @@ -1,179 +0,0 @@ - mov QWORD PTR [rsp+16], rbx - mov QWORD PTR [rsp+24], rbp - mov QWORD PTR [rsp+32], rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 64 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov ebp, 524288 - mov r8, QWORD PTR [rcx+32] - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movd xmm3, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movd xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - mov rdi, QWORD PTR [r9+104] - and r10d, 2097136 - movaps XMMWORD PTR [rsp+48], xmm6 - movd xmm4, rax - movaps XMMWORD PTR [rsp+32], xmm7 - movaps XMMWORD PTR [rsp+16], xmm8 - xorps xmm8, xmm8 - mov ax, 1023 - shl rax, 52 - movd xmm7, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm3, xmm0 - movd xmm0, rcx - punpcklqdq xmm4, xmm0 - - ALIGN(64) -main_loop_ryzen: - movdqa xmm5, XMMWORD PTR [r10+rbx] - movd xmm0, r11 - movd xmm6, r8 - punpcklqdq xmm6, xmm0 - lea rdx, QWORD PTR [r10+rbx] - lea r9, QWORD PTR [rdi+rdi] - shl rdi, 32 - - mov ecx, r10d - mov eax, r10d - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - aesenc xmm5, xmm6 - movdqa xmm2, XMMWORD PTR [rcx+rbx] - movdqa xmm1, XMMWORD PTR [rax+rbx] - movdqa xmm0, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - paddq xmm0, xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm0 - movdqa XMMWORD PTR [rax+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movaps xmm1, xmm8 - mov rsi, r15 - xor rsi, rdi - movd r14, xmm5 - movdqa xmm0, xmm5 - pxor xmm0, xmm3 - mov r10, r14 - and r10d, 2097136 - movdqa XMMWORD PTR [rdx], xmm0 - xor rsi, QWORD PTR [r10+rbx] - lea r12, QWORD PTR [r10+rbx] - mov r13, QWORD PTR [r10+rbx+8] - - add r9d, r14d - or r9d, -2147483647 - xor edx, edx - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movd rax, xmm0 - - div r9 - movd xmm0, rax - movd xmm1, rdx - punpckldq xmm0, xmm1 - movd r15, xmm0 - paddq xmm0, xmm5 - movdqa xmm2, xmm0 - psrlq xmm0, 12 - paddq xmm0, xmm7 - sqrtsd xmm1, xmm0 - movd rdi, xmm1 - test rdi, 524287 - je sqrt_fixup_ryzen - shr rdi, 19 - -sqrt_fixup_ryzen_ret: - mov rax, rsi - mul r14 - movd xmm1, rax - movd xmm0, rdx - punpcklqdq xmm0, xmm1 - - mov r9d, r10d - mov ecx, r10d - xor r9d, 16 - xor ecx, 32 - xor r10d, 48 - movdqa xmm1, XMMWORD PTR [rcx+rbx] - xor rdx, [rcx+rbx] - xor rax, [rcx+rbx+8] - movdqa xmm2, XMMWORD PTR [r9+rbx] - pxor xmm2, xmm0 - paddq xmm4, XMMWORD PTR [r10+rbx] - paddq xmm2, xmm3 - paddq xmm1, xmm6 - movdqa XMMWORD PTR [r9+rbx], xmm4 - movdqa XMMWORD PTR [rcx+rbx], xmm2 - movdqa XMMWORD PTR [r10+rbx], xmm1 - - movdqa xmm4, xmm3 - add r8, rdx - add r11, rax - mov QWORD PTR [r12], r8 - xor r8, rsi - mov QWORD PTR [r12+8], r11 - mov r10, r8 - xor r11, r13 - and r10d, 2097136 - movdqa xmm3, xmm5 - dec ebp - jne main_loop_ryzen - - ldmxcsr DWORD PTR [rsp] - movaps xmm6, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+64] - mov rbx, QWORD PTR [r11+56] - mov rbp, QWORD PTR [r11+64] - mov rsi, QWORD PTR [r11+72] - movaps xmm8, XMMWORD PTR [r11-48] - movaps xmm7, XMMWORD PTR [rsp+32] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - jmp cnv2_main_loop_ryzen_endp - -sqrt_fixup_ryzen: - movd r9, xmm2 - dec rdi - mov edx, -1022 - shl rdx, 32 - mov rax, rdi - shr rdi, 19 - shr rax, 20 - mov rcx, rdi - sub rcx, rax - lea rcx, [rcx+rdx+1] - add rax, rdx - imul rcx, rax - sub rcx, r9 - adc rdi, 0 - jmp sqrt_fixup_ryzen_ret - -cnv2_main_loop_ryzen_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_double_main_loop.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_double_main_loop.inc deleted file mode 100644 index 69ca8793ca..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_double_main_loop.inc +++ /dev/null @@ -1,410 +0,0 @@ - mov rax, rsp - push rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 184 - - stmxcsr DWORD PTR [rsp+272] - mov DWORD PTR [rsp+276], 24448 - ldmxcsr DWORD PTR [rsp+276] - - mov r13, QWORD PTR [rcx+224] - mov r9, rdx - mov r10, QWORD PTR [rcx+32] - mov r8, rcx - xor r10, QWORD PTR [rcx] - mov r14d, 393216 - mov r11, QWORD PTR [rcx+40] - xor r11, QWORD PTR [rcx+8] - mov rsi, QWORD PTR [rdx+224] - mov rdx, QWORD PTR [rcx+56] - xor rdx, QWORD PTR [rcx+24] - mov rdi, QWORD PTR [r9+32] - xor rdi, QWORD PTR [r9] - mov rbp, QWORD PTR [r9+40] - xor rbp, QWORD PTR [r9+8] - movd xmm0, rdx - movaps XMMWORD PTR [rax-88], xmm6 - movaps XMMWORD PTR [rax-104], xmm7 - movaps XMMWORD PTR [rax-120], xmm8 - movaps XMMWORD PTR [rsp+112], xmm9 - movaps XMMWORD PTR [rsp+96], xmm10 - movaps XMMWORD PTR [rsp+80], xmm11 - movaps XMMWORD PTR [rsp+64], xmm12 - movaps XMMWORD PTR [rsp+48], xmm13 - movaps XMMWORD PTR [rsp+32], xmm14 - movaps XMMWORD PTR [rsp+16], xmm15 - mov rdx, r10 - movd xmm4, QWORD PTR [r8+96] - and edx, 2097136 - mov rax, QWORD PTR [rcx+48] - xorps xmm13, xmm13 - xor rax, QWORD PTR [rcx+16] - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r8+72] - movd xmm5, QWORD PTR [r8+104] - movd xmm7, rax - - mov eax, 1 - shl rax, 52 - movd xmm14, rax - punpcklqdq xmm14, xmm14 - - mov eax, 1023 - shl rax, 52 - movd xmm12, rax - punpcklqdq xmm12, xmm12 - - mov rax, QWORD PTR [r8+80] - xor rax, QWORD PTR [r8+64] - punpcklqdq xmm7, xmm0 - movd xmm0, rcx - mov rcx, QWORD PTR [r9+56] - xor rcx, QWORD PTR [r9+24] - movd xmm3, rax - mov rax, QWORD PTR [r9+48] - xor rax, QWORD PTR [r9+16] - punpcklqdq xmm3, xmm0 - movd xmm0, rcx - mov QWORD PTR [rsp], r13 - mov rcx, QWORD PTR [r9+88] - xor rcx, QWORD PTR [r9+72] - movd xmm6, rax - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - punpcklqdq xmm6, xmm0 - movd xmm0, rcx - mov QWORD PTR [rsp+256], r10 - mov rcx, rdi - mov QWORD PTR [rsp+264], r11 - movd xmm8, rax - and ecx, 2097136 - punpcklqdq xmm8, xmm0 - movd xmm0, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movd xmm0, QWORD PTR [r9+104] - lea r8, QWORD PTR [rcx+rsi] - movdqu xmm11, XMMWORD PTR [r8] - punpcklqdq xmm5, xmm0 - lea r9, QWORD PTR [rdx+r13] - movdqu xmm15, XMMWORD PTR [r9] - - ALIGN(64) -rwz_main_loop_double: - movdqu xmm9, xmm15 - mov eax, edx - mov ebx, edx - xor eax, 16 - xor ebx, 32 - xor edx, 48 - - movd xmm0, r11 - movd xmm2, r10 - punpcklqdq xmm2, xmm0 - aesenc xmm9, xmm2 - - movdqu xmm0, XMMWORD PTR [rdx+r13] - movdqu xmm1, XMMWORD PTR [rbx+r13] - paddq xmm0, xmm7 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [rbx+r13], xmm0 - movdqu xmm0, XMMWORD PTR [rax+r13] - movdqu XMMWORD PTR [rdx+r13], xmm1 - paddq xmm0, xmm3 - movdqu XMMWORD PTR [rax+r13], xmm0 - - movd r11, xmm9 - mov edx, r11d - and edx, 2097136 - movdqa xmm0, xmm9 - pxor xmm0, xmm7 - movdqu XMMWORD PTR [r9], xmm0 - - lea rbx, QWORD PTR [rdx+r13] - mov r10, QWORD PTR [rdx+r13] - - movdqu xmm10, xmm11 - movd xmm0, rbp - movd xmm11, rdi - punpcklqdq xmm11, xmm0 - aesenc xmm10, xmm11 - - mov eax, ecx - mov r12d, ecx - xor eax, 16 - xor r12d, 32 - xor ecx, 48 - - movdqu xmm0, XMMWORD PTR [rcx+rsi] - paddq xmm0, xmm6 - movdqu xmm1, XMMWORD PTR [r12+rsi] - movdqu XMMWORD PTR [r12+rsi], xmm0 - paddq xmm1, xmm11 - movdqu xmm0, XMMWORD PTR [rax+rsi] - movdqu XMMWORD PTR [rcx+rsi], xmm1 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [rax+rsi], xmm0 - - movd rcx, xmm10 - and ecx, 2097136 - - movdqa xmm0, xmm10 - pxor xmm0, xmm6 - movdqu XMMWORD PTR [r8], xmm0 - mov r12, QWORD PTR [rcx+rsi] - - mov r9, QWORD PTR [rbx+8] - - xor edx, 16 - mov r8d, edx - mov r15d, edx - - movd rdx, xmm5 - shl rdx, 32 - movd rax, xmm4 - xor rdx, rax - xor r10, rdx - mov rax, r10 - mul r11 - mov r11d, r8d - xor r11d, 48 - movd xmm0, rdx - xor rdx, [r11+r13] - movd xmm1, rax - xor rax, [r11+r13+8] - punpcklqdq xmm0, xmm1 - - pxor xmm0, XMMWORD PTR [r8+r13] - movdqu xmm1, XMMWORD PTR [r11+r13] - paddq xmm0, xmm3 - paddq xmm1, xmm2 - movdqu XMMWORD PTR [r8+r13], xmm0 - xor r8d, 32 - movdqu xmm0, XMMWORD PTR [r8+r13] - movdqu XMMWORD PTR [r8+r13], xmm1 - paddq xmm0, xmm7 - movdqu XMMWORD PTR [r11+r13], xmm0 - - mov r11, QWORD PTR [rsp+256] - add r11, rdx - mov rdx, QWORD PTR [rsp+264] - add rdx, rax - mov QWORD PTR [rbx], r11 - xor r11, r10 - mov QWORD PTR [rbx+8], rdx - xor rdx, r9 - mov QWORD PTR [rsp+256], r11 - and r11d, 2097136 - mov QWORD PTR [rsp+264], rdx - mov QWORD PTR [rsp+8], r11 - lea r15, QWORD PTR [r11+r13] - movdqu xmm15, XMMWORD PTR [r11+r13] - lea r13, QWORD PTR [rsi+rcx] - movdqa xmm0, xmm5 - psrldq xmm0, 8 - movaps xmm2, xmm13 - movd r10, xmm0 - psllq xmm5, 1 - shl r10, 32 - movdqa xmm0, xmm9 - psrldq xmm0, 8 - movdqa xmm1, xmm10 - movd r11, xmm0 - psrldq xmm1, 8 - movd r8, xmm1 - psrldq xmm4, 8 - movaps xmm0, xmm13 - movd rax, xmm4 - xor r10, rax - movaps xmm1, xmm13 - xor r10, r12 - lea rax, QWORD PTR [r11+1] - shr rax, 1 - movdqa xmm3, xmm9 - punpcklqdq xmm3, xmm10 - paddq xmm5, xmm3 - movd rdx, xmm5 - psrldq xmm5, 8 - cvtsi2sd xmm2, rax - or edx, -2147483647 - lea rax, QWORD PTR [r8+1] - shr rax, 1 - movd r9, xmm5 - cvtsi2sd xmm0, rax - or r9d, -2147483647 - cvtsi2sd xmm1, rdx - unpcklpd xmm2, xmm0 - movaps xmm0, xmm13 - cvtsi2sd xmm0, r9 - unpcklpd xmm1, xmm0 - divpd xmm2, xmm1 - paddq xmm2, xmm14 - cvttsd2si rax, xmm2 - psrldq xmm2, 8 - mov rbx, rax - imul rax, rdx - sub r11, rax - js rwz_div_fix_1 -rwz_div_fix_1_ret: - - cvttsd2si rdx, xmm2 - mov rax, rdx - imul rax, r9 - movd xmm2, r11d - movd xmm4, ebx - sub r8, rax - js rwz_div_fix_2 -rwz_div_fix_2_ret: - - movd xmm1, r8d - movd xmm0, edx - punpckldq xmm2, xmm1 - punpckldq xmm4, xmm0 - punpckldq xmm4, xmm2 - paddq xmm3, xmm4 - movdqa xmm0, xmm3 - psrlq xmm0, 12 - paddq xmm0, xmm12 - sqrtpd xmm1, xmm0 - movd r9, xmm1 - movdqa xmm5, xmm1 - psrlq xmm5, 19 - test r9, 524287 - je rwz_sqrt_fix_1 -rwz_sqrt_fix_1_ret: - - movd r9, xmm10 - psrldq xmm1, 8 - movd r8, xmm1 - test r8, 524287 - je rwz_sqrt_fix_2 -rwz_sqrt_fix_2_ret: - - mov r12d, ecx - mov r8d, ecx - xor r12d, 16 - xor r8d, 32 - xor ecx, 48 - mov rax, r10 - mul r9 - movd xmm0, rax - movd xmm3, rdx - punpcklqdq xmm3, xmm0 - - movdqu xmm0, XMMWORD PTR [r12+rsi] - pxor xmm0, xmm3 - movdqu xmm1, XMMWORD PTR [r8+rsi] - xor rdx, [r8+rsi] - xor rax, [r8+rsi+8] - movdqu xmm3, XMMWORD PTR [rcx+rsi] - paddq xmm3, xmm6 - paddq xmm1, xmm11 - paddq xmm0, xmm8 - movdqu XMMWORD PTR [r8+rsi], xmm3 - movdqu XMMWORD PTR [rcx+rsi], xmm1 - movdqu XMMWORD PTR [r12+rsi], xmm0 - - add rdi, rdx - mov QWORD PTR [r13], rdi - xor rdi, r10 - mov ecx, edi - and ecx, 2097136 - lea r8, QWORD PTR [rcx+rsi] - - mov rdx, QWORD PTR [r13+8] - add rbp, rax - mov QWORD PTR [r13+8], rbp - movdqu xmm11, XMMWORD PTR [rcx+rsi] - xor rbp, rdx - mov r13, QWORD PTR [rsp] - movdqa xmm3, xmm7 - mov rdx, QWORD PTR [rsp+8] - movdqa xmm8, xmm6 - mov r10, QWORD PTR [rsp+256] - movdqa xmm7, xmm9 - mov r11, QWORD PTR [rsp+264] - movdqa xmm6, xmm10 - mov r9, r15 - dec r14d - jne rwz_main_loop_double - - ldmxcsr DWORD PTR [rsp+272] - movaps xmm13, XMMWORD PTR [rsp+48] - lea r11, QWORD PTR [rsp+184] - movaps xmm6, XMMWORD PTR [r11-24] - movaps xmm7, XMMWORD PTR [r11-40] - movaps xmm8, XMMWORD PTR [r11-56] - movaps xmm9, XMMWORD PTR [r11-72] - movaps xmm10, XMMWORD PTR [r11-88] - movaps xmm11, XMMWORD PTR [r11-104] - movaps xmm12, XMMWORD PTR [r11-120] - movaps xmm14, XMMWORD PTR [rsp+32] - movaps xmm15, XMMWORD PTR [rsp+16] - mov rsp, r11 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - pop rbx - jmp rwz_cnv2_double_mainloop_asm_endp - -rwz_div_fix_1: - dec rbx - add r11, rdx - jmp rwz_div_fix_1_ret - -rwz_div_fix_2: - dec rdx - add r8, r9 - jmp rwz_div_fix_2_ret - -rwz_sqrt_fix_1: - movd r8, xmm3 - movdqa xmm0, xmm5 - psrldq xmm0, 8 - dec r9 - mov r11d, -1022 - shl r11, 32 - mov rax, r9 - shr r9, 19 - shr rax, 20 - mov rdx, r9 - sub rdx, rax - lea rdx, [rdx+r11+1] - add rax, r11 - imul rdx, rax - sub rdx, r8 - adc r9, 0 - movd xmm5, r9 - punpcklqdq xmm5, xmm0 - jmp rwz_sqrt_fix_1_ret - -rwz_sqrt_fix_2: - psrldq xmm3, 8 - movd r11, xmm3 - dec r8 - mov ebx, -1022 - shl rbx, 32 - mov rax, r8 - shr r8, 19 - shr rax, 20 - mov rdx, r8 - sub rdx, rax - lea rdx, [rdx+rbx+1] - add rax, rbx - imul rdx, rax - sub rdx, r11 - adc r8, 0 - movd xmm0, r8 - punpcklqdq xmm5, xmm0 - jmp rwz_sqrt_fix_2_ret - -rwz_cnv2_double_mainloop_asm_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_main_loop.inc b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_main_loop.inc deleted file mode 100644 index 9931773056..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn2/cnv2_rwz_main_loop.inc +++ /dev/null @@ -1,186 +0,0 @@ - mov QWORD PTR [rsp+24], rbx - push rbp - push rsi - push rdi - push r12 - push r13 - push r14 - push r15 - sub rsp, 80 - - stmxcsr DWORD PTR [rsp] - mov DWORD PTR [rsp+4], 24448 - ldmxcsr DWORD PTR [rsp+4] - - mov rax, QWORD PTR [rcx+48] - mov r9, rcx - xor rax, QWORD PTR [rcx+16] - mov esi, 393216 - mov r8, QWORD PTR [rcx+32] - mov r13d, -2147483647 - xor r8, QWORD PTR [rcx] - mov r11, QWORD PTR [rcx+40] - mov r10, r8 - mov rdx, QWORD PTR [rcx+56] - movd xmm4, rax - xor rdx, QWORD PTR [rcx+24] - xor r11, QWORD PTR [rcx+8] - mov rbx, QWORD PTR [rcx+224] - mov rax, QWORD PTR [r9+80] - xor rax, QWORD PTR [r9+64] - movd xmm0, rdx - mov rcx, QWORD PTR [rcx+88] - xor rcx, QWORD PTR [r9+72] - movd xmm3, QWORD PTR [r9+104] - movaps XMMWORD PTR [rsp+64], xmm6 - movaps XMMWORD PTR [rsp+48], xmm7 - movaps XMMWORD PTR [rsp+32], xmm8 - and r10d, 2097136 - movd xmm5, rax - - xor eax, eax - mov QWORD PTR [rsp+16], rax - - mov ax, 1023 - shl rax, 52 - movd xmm8, rax - mov r15, QWORD PTR [r9+96] - punpcklqdq xmm4, xmm0 - movd xmm0, rcx - punpcklqdq xmm5, xmm0 - movdqu xmm6, XMMWORD PTR [r10+rbx] - - ALIGN(64) -rwz_main_loop: - lea rdx, QWORD PTR [r10+rbx] - mov ecx, r10d - mov eax, r10d - mov rdi, r15 - xor ecx, 16 - xor eax, 32 - xor r10d, 48 - movd xmm0, r11 - movd xmm7, r8 - punpcklqdq xmm7, xmm0 - aesenc xmm6, xmm7 - movd rbp, xmm6 - mov r9, rbp - and r9d, 2097136 - movdqu xmm0, XMMWORD PTR [rcx+rbx] - movdqu xmm1, XMMWORD PTR [rax+rbx] - movdqu xmm2, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm5 - paddq xmm1, xmm7 - paddq xmm2, xmm4 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [rax+rbx], xmm2 - movdqu XMMWORD PTR [r10+rbx], xmm1 - mov r10, r9 - xor r10d, 32 - movd rcx, xmm3 - mov rax, rcx - shl rax, 32 - xor rdi, rax - movdqa xmm0, xmm6 - pxor xmm0, xmm4 - movdqu XMMWORD PTR [rdx], xmm0 - xor rdi, QWORD PTR [r9+rbx] - lea r14, QWORD PTR [r9+rbx] - mov r12, QWORD PTR [r14+8] - xor edx, edx - lea r9d, DWORD PTR [ecx+ecx] - add r9d, ebp - movdqa xmm0, xmm6 - psrldq xmm0, 8 - or r9d, r13d - movd rax, xmm0 - div r9 - xorps xmm3, xmm3 - mov eax, eax - shl rdx, 32 - add rdx, rax - lea r9, QWORD PTR [rdx+rbp] - mov r15, rdx - mov rax, r9 - shr rax, 12 - movd xmm0, rax - paddq xmm0, xmm8 - sqrtsd xmm3, xmm0 - psubq xmm3, XMMWORD PTR [rsp+16] - movd rdx, xmm3 - test edx, 524287 - je rwz_sqrt_fixup - psrlq xmm3, 19 -rwz_sqrt_fixup_ret: - - mov ecx, r10d - mov rax, rdi - mul rbp - movd xmm2, rdx - xor rdx, [rcx+rbx] - add r8, rdx - mov QWORD PTR [r14], r8 - xor r8, rdi - mov edi, r8d - and edi, 2097136 - movd xmm0, rax - xor rax, [rcx+rbx+8] - add r11, rax - mov QWORD PTR [r14+8], r11 - punpcklqdq xmm2, xmm0 - - mov r9d, r10d - xor r9d, 48 - xor r10d, 16 - pxor xmm2, XMMWORD PTR [r9+rbx] - movdqu xmm0, XMMWORD PTR [r10+rbx] - paddq xmm0, xmm4 - movdqu xmm1, XMMWORD PTR [rcx+rbx] - paddq xmm2, xmm5 - paddq xmm1, xmm7 - movdqa xmm5, xmm4 - movdqu XMMWORD PTR [r9+rbx], xmm2 - movdqa xmm4, xmm6 - movdqu XMMWORD PTR [rcx+rbx], xmm0 - movdqu XMMWORD PTR [r10+rbx], xmm1 - movdqu xmm6, [rdi+rbx] - mov r10d, edi - xor r11, r12 - dec rsi - jne rwz_main_loop - - ldmxcsr DWORD PTR [rsp] - mov rbx, QWORD PTR [rsp+160] - movaps xmm6, XMMWORD PTR [rsp+64] - movaps xmm7, XMMWORD PTR [rsp+48] - movaps xmm8, XMMWORD PTR [rsp+32] - add rsp, 80 - pop r15 - pop r14 - pop r13 - pop r12 - pop rdi - pop rsi - pop rbp - jmp cnv2_rwz_main_loop_endp - -rwz_sqrt_fixup: - dec rdx - mov r13d, -1022 - shl r13, 32 - mov rax, rdx - shr rdx, 19 - shr rax, 20 - mov rcx, rdx - sub rcx, rax - add rax, r13 - not r13 - sub rcx, r13 - mov r13d, -2147483647 - imul rcx, rax - sub rcx, r9 - adc rdx, 0 - movd xmm3, rdx - jmp rwz_sqrt_fixup_ret - -cnv2_rwz_main_loop_endp: diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.S b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.S deleted file mode 100644 index 63c3a8ba65..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.S +++ /dev/null @@ -1,45 +0,0 @@ -#define ALIGN(x) .align 64 -.intel_syntax noprefix -.section .text -.global cnv2_mainloop_ivybridge_asm -.global cnv2_mainloop_ryzen_asm -.global cnv2_mainloop_bulldozer_asm -.global cnv2_double_mainloop_sandybridge_asm -.global cnv2_rwz_mainloop_asm -.global cnv2_rwz_double_mainloop_asm - -ALIGN(64) -cnv2_mainloop_ivybridge_asm: - #include "../cn2/cnv2_main_loop_ivybridge.inc" - ret 0 - mov eax, 3735929054 - -ALIGN(64) -cnv2_mainloop_ryzen_asm: - #include "../cn2/cnv2_main_loop_ryzen.inc" - ret 0 - mov eax, 3735929054 - -ALIGN(64) -cnv2_mainloop_bulldozer_asm: - #include "../cn2/cnv2_main_loop_bulldozer.inc" - ret 0 - mov eax, 3735929054 - -ALIGN(64) -cnv2_double_mainloop_sandybridge_asm: - #include "../cn2/cnv2_double_main_loop_sandybridge.inc" - ret 0 - mov eax, 3735929054 - -ALIGN(64) -cnv2_rwz_mainloop_asm: - #include "cn2/cnv2_rwz_main_loop.inc" - ret 0 - mov eax, 3735929054 - -ALIGN(64) -cnv2_rwz_double_mainloop_asm: - #include "cn2/cnv2_rwz_double_main_loop.inc" - ret 0 - mov eax, 3735929054 diff --git a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.asm b/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.asm deleted file mode 100644 index 57246cf5ca..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/asm/win64/cn_main_loop.asm +++ /dev/null @@ -1,52 +0,0 @@ -_TEXT_CNV2_MAINLOOP SEGMENT PAGE READ EXECUTE -PUBLIC cnv2_mainloop_ivybridge_asm -PUBLIC cnv2_mainloop_ryzen_asm -PUBLIC cnv2_mainloop_bulldozer_asm -PUBLIC cnv2_double_mainloop_sandybridge_asm -PUBLIC cnv2_rwz_mainloop_asm -PUBLIC cnv2_rwz_double_mainloop_asm - -ALIGN 64 -cnv2_mainloop_ivybridge_asm PROC - INCLUDE cn2/cnv2_main_loop_ivybridge.inc - ret 0 - mov eax, 3735929054 -cnv2_mainloop_ivybridge_asm ENDP - -ALIGN 64 -cnv2_mainloop_ryzen_asm PROC - INCLUDE cn2/cnv2_main_loop_ryzen.inc - ret 0 - mov eax, 3735929054 -cnv2_mainloop_ryzen_asm ENDP - -ALIGN 64 -cnv2_mainloop_bulldozer_asm PROC - INCLUDE cn2/cnv2_main_loop_bulldozer.inc - ret 0 - mov eax, 3735929054 -cnv2_mainloop_bulldozer_asm ENDP - -ALIGN 64 -cnv2_double_mainloop_sandybridge_asm PROC - INCLUDE cn2/cnv2_double_main_loop_sandybridge.inc - ret 0 - mov eax, 3735929054 -cnv2_double_mainloop_sandybridge_asm ENDP - -ALIGN(64) -cnv2_rwz_mainloop_asm PROC - INCLUDE cn2/cnv2_rwz_main_loop.inc - ret 0 - mov eax, 3735929054 -cnv2_rwz_mainloop_asm ENDP - -ALIGN(64) -cnv2_rwz_double_mainloop_asm PROC - INCLUDE cn2/cnv2_rwz_double_main_loop.inc - ret 0 - mov eax, 3735929054 -cnv2_rwz_double_mainloop_asm ENDP - -_TEXT_CNV2_MAINLOOP ENDS -END diff --git a/src/Native/libcryptonight/xmrig/crypto/c_blake256.c b/src/Native/libcryptonight/xmrig/crypto/c_blake256.c deleted file mode 100644 index 00a84c229f..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_blake256.c +++ /dev/null @@ -1,326 +0,0 @@ -/* - * The blake256_* and blake224_* functions are largely copied from - * blake256_light.c and blake224_light.c from the BLAKE website: - * - * http://131002.net/blake/ - * - * The hmac_* functions implement HMAC-BLAKE-256 and HMAC-BLAKE-224. - * HMAC is specified by RFC 2104. - */ - -#include -#include -#include -#include "c_blake256.h" - -#define U8TO32(p) \ - (((uint32_t)((p)[0]) << 24) | ((uint32_t)((p)[1]) << 16) | \ - ((uint32_t)((p)[2]) << 8) | ((uint32_t)((p)[3]) )) -#define U32TO8(p, v) \ - (p)[0] = (uint8_t)((v) >> 24); (p)[1] = (uint8_t)((v) >> 16); \ - (p)[2] = (uint8_t)((v) >> 8); (p)[3] = (uint8_t)((v) ); - -const uint8_t sigma[][16] = { - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}, - {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3}, - {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4}, - { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8}, - { 9, 0, 5, 7, 2, 4,10,15,14, 1,11,12, 6, 8, 3,13}, - { 2,12, 6,10, 0,11, 8, 3, 4,13, 7, 5,15,14, 1, 9}, - {12, 5, 1,15,14,13, 4,10, 0, 7, 6, 3, 9, 2, 8,11}, - {13,11, 7,14,12, 1, 3, 9, 5, 0,15, 4, 8, 6, 2,10}, - { 6,15,14, 9,11, 3, 0, 8,12, 2,13, 7, 1, 4,10, 5}, - {10, 2, 8, 4, 7, 6, 1, 5,15,11, 9,14, 3,12,13, 0}, - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15}, - {14,10, 4, 8, 9,15,13, 6, 1,12, 0, 2,11, 7, 5, 3}, - {11, 8,12, 0, 5, 2,15,13,10,14, 3, 6, 7, 1, 9, 4}, - { 7, 9, 3, 1,13,12,11,14, 2, 6, 5,10, 4, 0,15, 8} -}; - -const uint32_t cst[16] = { - 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, - 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, - 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, - 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917 -}; - -static const uint8_t padding[] = { - 0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 -}; - - -void blake256_compress(state *S, const uint8_t *block) { - uint32_t v[16], m[16], i; - -#define ROT(x,n) (((x)<<(32-n))|((x)>>(n))) -#define G(a,b,c,d,e) \ - v[a] += (m[sigma[i][e]] ^ cst[sigma[i][e+1]]) + v[b]; \ - v[d] = ROT(v[d] ^ v[a],16); \ - v[c] += v[d]; \ - v[b] = ROT(v[b] ^ v[c],12); \ - v[a] += (m[sigma[i][e+1]] ^ cst[sigma[i][e]])+v[b]; \ - v[d] = ROT(v[d] ^ v[a], 8); \ - v[c] += v[d]; \ - v[b] = ROT(v[b] ^ v[c], 7); - - for (i = 0; i < 16; ++i) m[i] = U8TO32(block + i * 4); - for (i = 0; i < 8; ++i) v[i] = S->h[i]; - v[ 8] = S->s[0] ^ 0x243F6A88; - v[ 9] = S->s[1] ^ 0x85A308D3; - v[10] = S->s[2] ^ 0x13198A2E; - v[11] = S->s[3] ^ 0x03707344; - v[12] = 0xA4093822; - v[13] = 0x299F31D0; - v[14] = 0x082EFA98; - v[15] = 0xEC4E6C89; - - if (S->nullt == 0) { - v[12] ^= S->t[0]; - v[13] ^= S->t[0]; - v[14] ^= S->t[1]; - v[15] ^= S->t[1]; - } - - for (i = 0; i < 14; ++i) { - G(0, 4, 8, 12, 0); - G(1, 5, 9, 13, 2); - G(2, 6, 10, 14, 4); - G(3, 7, 11, 15, 6); - G(3, 4, 9, 14, 14); - G(2, 7, 8, 13, 12); - G(0, 5, 10, 15, 8); - G(1, 6, 11, 12, 10); - } - - for (i = 0; i < 16; ++i) S->h[i % 8] ^= v[i]; - for (i = 0; i < 8; ++i) S->h[i] ^= S->s[i % 4]; -} - -void blake256_init(state *S) { - S->h[0] = 0x6A09E667; - S->h[1] = 0xBB67AE85; - S->h[2] = 0x3C6EF372; - S->h[3] = 0xA54FF53A; - S->h[4] = 0x510E527F; - S->h[5] = 0x9B05688C; - S->h[6] = 0x1F83D9AB; - S->h[7] = 0x5BE0CD19; - S->t[0] = S->t[1] = S->buflen = S->nullt = 0; - S->s[0] = S->s[1] = S->s[2] = S->s[3] = 0; -} - -void blake224_init(state *S) { - S->h[0] = 0xC1059ED8; - S->h[1] = 0x367CD507; - S->h[2] = 0x3070DD17; - S->h[3] = 0xF70E5939; - S->h[4] = 0xFFC00B31; - S->h[5] = 0x68581511; - S->h[6] = 0x64F98FA7; - S->h[7] = 0xBEFA4FA4; - S->t[0] = S->t[1] = S->buflen = S->nullt = 0; - S->s[0] = S->s[1] = S->s[2] = S->s[3] = 0; -} - -// datalen = number of bits -void blake256_update(state *S, const uint8_t *data, uint64_t datalen) { - int left = S->buflen >> 3; - int fill = 64 - left; - - if (left && (((datalen >> 3) & 0x3F) >= (unsigned) fill)) { - memcpy((void *) (S->buf + left), (void *) data, fill); - S->t[0] += 512; - if (S->t[0] == 0) S->t[1]++; - blake256_compress(S, S->buf); - data += fill; - datalen -= (fill << 3); - left = 0; - } - - while (datalen >= 512) { - S->t[0] += 512; - if (S->t[0] == 0) S->t[1]++; - blake256_compress(S, data); - data += 64; - datalen -= 512; - } - - if (datalen > 0) { - memcpy((void *) (S->buf + left), (void *) data, datalen >> 3); - S->buflen = (left << 3) + (int) datalen; - } else { - S->buflen = 0; - } -} - -// datalen = number of bits -void blake224_update(state *S, const uint8_t *data, uint64_t datalen) { - blake256_update(S, data, datalen); -} - -void blake256_final_h(state *S, uint8_t *digest, uint8_t pa, uint8_t pb) { - uint8_t msglen[8]; - uint32_t lo = S->t[0] + S->buflen, hi = S->t[1]; - if (lo < (unsigned) S->buflen) hi++; - U32TO8(msglen + 0, hi); - U32TO8(msglen + 4, lo); - - if (S->buflen == 440) { /* one padding byte */ - S->t[0] -= 8; - blake256_update(S, &pa, 8); - } else { - if (S->buflen < 440) { /* enough space to fill the block */ - if (S->buflen == 0) S->nullt = 1; - S->t[0] -= 440 - S->buflen; - blake256_update(S, padding, 440 - S->buflen); - } else { /* need 2 compressions */ - S->t[0] -= 512 - S->buflen; - blake256_update(S, padding, 512 - S->buflen); - S->t[0] -= 440; - blake256_update(S, padding + 1, 440); - S->nullt = 1; - } - blake256_update(S, &pb, 8); - S->t[0] -= 8; - } - S->t[0] -= 64; - blake256_update(S, msglen, 64); - - U32TO8(digest + 0, S->h[0]); - U32TO8(digest + 4, S->h[1]); - U32TO8(digest + 8, S->h[2]); - U32TO8(digest + 12, S->h[3]); - U32TO8(digest + 16, S->h[4]); - U32TO8(digest + 20, S->h[5]); - U32TO8(digest + 24, S->h[6]); - U32TO8(digest + 28, S->h[7]); -} - -void blake256_final(state *S, uint8_t *digest) { - blake256_final_h(S, digest, 0x81, 0x01); -} - -void blake224_final(state *S, uint8_t *digest) { - blake256_final_h(S, digest, 0x80, 0x00); -} - -// inlen = number of bytes -void blake256_hash(uint8_t *out, const uint8_t *in, uint64_t inlen) { - state S; - blake256_init(&S); - blake256_update(&S, in, inlen * 8); - blake256_final(&S, out); -} - -// inlen = number of bytes -void blake224_hash(uint8_t *out, const uint8_t *in, uint64_t inlen) { - state S; - blake224_init(&S); - blake224_update(&S, in, inlen * 8); - blake224_final(&S, out); -} - -// keylen = number of bytes -void hmac_blake256_init(hmac_state *S, const uint8_t *_key, uint64_t keylen) { - const uint8_t *key = _key; - uint8_t keyhash[32]; - uint8_t pad[64]; - uint64_t i; - - if (keylen > 64) { - blake256_hash(keyhash, key, keylen); - key = keyhash; - keylen = 32; - } - - blake256_init(&S->inner); - memset(pad, 0x36, 64); - for (i = 0; i < keylen; ++i) { - pad[i] ^= key[i]; - } - blake256_update(&S->inner, pad, 512); - - blake256_init(&S->outer); - memset(pad, 0x5c, 64); - for (i = 0; i < keylen; ++i) { - pad[i] ^= key[i]; - } - blake256_update(&S->outer, pad, 512); - - memset(keyhash, 0, 32); -} - -// keylen = number of bytes -void hmac_blake224_init(hmac_state *S, const uint8_t *_key, uint64_t keylen) { - const uint8_t *key = _key; - uint8_t keyhash[32]; - uint8_t pad[64]; - uint64_t i; - - if (keylen > 64) { - blake256_hash(keyhash, key, keylen); - key = keyhash; - keylen = 28; - } - - blake224_init(&S->inner); - memset(pad, 0x36, 64); - for (i = 0; i < keylen; ++i) { - pad[i] ^= key[i]; - } - blake224_update(&S->inner, pad, 512); - - blake224_init(&S->outer); - memset(pad, 0x5c, 64); - for (i = 0; i < keylen; ++i) { - pad[i] ^= key[i]; - } - blake224_update(&S->outer, pad, 512); - - memset(keyhash, 0, 32); -} - -// datalen = number of bits -void hmac_blake256_update(hmac_state *S, const uint8_t *data, uint64_t datalen) { - // update the inner state - blake256_update(&S->inner, data, datalen); -} - -// datalen = number of bits -void hmac_blake224_update(hmac_state *S, const uint8_t *data, uint64_t datalen) { - // update the inner state - blake224_update(&S->inner, data, datalen); -} - -void hmac_blake256_final(hmac_state *S, uint8_t *digest) { - uint8_t ihash[32]; - blake256_final(&S->inner, ihash); - blake256_update(&S->outer, ihash, 256); - blake256_final(&S->outer, digest); - memset(ihash, 0, 32); -} - -void hmac_blake224_final(hmac_state *S, uint8_t *digest) { - uint8_t ihash[32]; - blake224_final(&S->inner, ihash); - blake224_update(&S->outer, ihash, 224); - blake224_final(&S->outer, digest); - memset(ihash, 0, 32); -} - -// keylen = number of bytes; inlen = number of bytes -void hmac_blake256_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint64_t inlen) { - hmac_state S; - hmac_blake256_init(&S, key, keylen); - hmac_blake256_update(&S, in, inlen * 8); - hmac_blake256_final(&S, out); -} - -// keylen = number of bytes; inlen = number of bytes -void hmac_blake224_hash(uint8_t *out, const uint8_t *key, uint64_t keylen, const uint8_t *in, uint64_t inlen) { - hmac_state S; - hmac_blake224_init(&S, key, keylen); - hmac_blake224_update(&S, in, inlen * 8); - hmac_blake224_final(&S, out); -} diff --git a/src/Native/libcryptonight/xmrig/crypto/c_blake256.h b/src/Native/libcryptonight/xmrig/crypto/c_blake256.h deleted file mode 100644 index b9c2aad0df..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_blake256.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _BLAKE256_H_ -#define _BLAKE256_H_ - -#include - -typedef struct { - uint32_t h[8], s[4], t[2]; - int buflen, nullt; - uint8_t buf[64]; -} state; - -typedef struct { - state inner; - state outer; -} hmac_state; - -void blake256_init(state *); -void blake224_init(state *); - -void blake256_update(state *, const uint8_t *, uint64_t); -void blake224_update(state *, const uint8_t *, uint64_t); - -void blake256_final(state *, uint8_t *); -void blake224_final(state *, uint8_t *); - -void blake256_hash(uint8_t *, const uint8_t *, uint64_t); -void blake224_hash(uint8_t *, const uint8_t *, uint64_t); - -/* HMAC functions: */ - -void hmac_blake256_init(hmac_state *, const uint8_t *, uint64_t); -void hmac_blake224_init(hmac_state *, const uint8_t *, uint64_t); - -void hmac_blake256_update(hmac_state *, const uint8_t *, uint64_t); -void hmac_blake224_update(hmac_state *, const uint8_t *, uint64_t); - -void hmac_blake256_final(hmac_state *, uint8_t *); -void hmac_blake224_final(hmac_state *, uint8_t *); - -void hmac_blake256_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); -void hmac_blake224_hash(uint8_t *, const uint8_t *, uint64_t, const uint8_t *, uint64_t); - -#endif /* _BLAKE256_H_ */ diff --git a/src/Native/libcryptonight/xmrig/crypto/c_groestl.c b/src/Native/libcryptonight/xmrig/crypto/c_groestl.c deleted file mode 100644 index 0f57ea128e..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_groestl.c +++ /dev/null @@ -1,360 +0,0 @@ -/* hash.c April 2012 - * Groestl ANSI C code optimised for 32-bit machines - * Author: Thomas Krinninger - * - * This work is based on the implementation of - * Soeren S. Thomsen and Krystian Matusiewicz - * - * - */ - -#include "c_groestl.h" -#include "groestl_tables.h" - -#define P_TYPE 0 -#define Q_TYPE 1 - -const uint8_t shift_Values[2][8] = {{0,1,2,3,4,5,6,7},{1,3,5,7,0,2,4,6}}; - -const uint8_t indices_cyclic[15] = {0,1,2,3,4,5,6,7,0,1,2,3,4,5,6}; - - -#define ROTATE_COLUMN_DOWN(v1, v2, amount_bytes, temp_var) {temp_var = (v1<<(8*amount_bytes))|(v2>>(8*(4-amount_bytes))); \ - v2 = (v2<<(8*amount_bytes))|(v1>>(8*(4-amount_bytes))); \ - v1 = temp_var;} - - -#define COLUMN(x,y,i,c0,c1,c2,c3,c4,c5,c6,c7,tv1,tv2,tu,tl,t) \ - tu = T[2*(uint32_t)x[4*c0+0]]; \ - tl = T[2*(uint32_t)x[4*c0+0]+1]; \ - tv1 = T[2*(uint32_t)x[4*c1+1]]; \ - tv2 = T[2*(uint32_t)x[4*c1+1]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \ - tu ^= tv1; \ - tl ^= tv2; \ - tv1 = T[2*(uint32_t)x[4*c2+2]]; \ - tv2 = T[2*(uint32_t)x[4*c2+2]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \ - tu ^= tv1; \ - tl ^= tv2; \ - tv1 = T[2*(uint32_t)x[4*c3+3]]; \ - tv2 = T[2*(uint32_t)x[4*c3+3]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \ - tu ^= tv1; \ - tl ^= tv2; \ - tl ^= T[2*(uint32_t)x[4*c4+0]]; \ - tu ^= T[2*(uint32_t)x[4*c4+0]+1]; \ - tv1 = T[2*(uint32_t)x[4*c5+1]]; \ - tv2 = T[2*(uint32_t)x[4*c5+1]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,1,t) \ - tl ^= tv1; \ - tu ^= tv2; \ - tv1 = T[2*(uint32_t)x[4*c6+2]]; \ - tv2 = T[2*(uint32_t)x[4*c6+2]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,2,t) \ - tl ^= tv1; \ - tu ^= tv2; \ - tv1 = T[2*(uint32_t)x[4*c7+3]]; \ - tv2 = T[2*(uint32_t)x[4*c7+3]+1]; \ - ROTATE_COLUMN_DOWN(tv1,tv2,3,t) \ - tl ^= tv1; \ - tu ^= tv2; \ - y[i] = tu; \ - y[i+1] = tl; - - -/* compute one round of P (short variants) */ -static void RND512P(uint8_t *x, uint32_t *y, uint32_t r) { - uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp; - uint32_t* x32 = (uint32_t*)x; - x32[ 0] ^= 0x00000000^r; - x32[ 2] ^= 0x00000010^r; - x32[ 4] ^= 0x00000020^r; - x32[ 6] ^= 0x00000030^r; - x32[ 8] ^= 0x00000040^r; - x32[10] ^= 0x00000050^r; - x32[12] ^= 0x00000060^r; - x32[14] ^= 0x00000070^r; - COLUMN(x,y, 0, 0, 2, 4, 6, 9, 11, 13, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 2, 2, 4, 6, 8, 11, 13, 15, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 4, 4, 6, 8, 10, 13, 15, 1, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 6, 6, 8, 10, 12, 15, 1, 3, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 8, 8, 10, 12, 14, 1, 3, 5, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,10, 10, 12, 14, 0, 3, 5, 7, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,12, 12, 14, 0, 2, 5, 7, 9, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,14, 14, 0, 2, 4, 7, 9, 11, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); -} - -/* compute one round of Q (short variants) */ -static void RND512Q(uint8_t *x, uint32_t *y, uint32_t r) { - uint32_t temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp; - uint32_t* x32 = (uint32_t*)x; - x32[ 0] = ~x32[ 0]; - x32[ 1] ^= 0xffffffff^r; - x32[ 2] = ~x32[ 2]; - x32[ 3] ^= 0xefffffff^r; - x32[ 4] = ~x32[ 4]; - x32[ 5] ^= 0xdfffffff^r; - x32[ 6] = ~x32[ 6]; - x32[ 7] ^= 0xcfffffff^r; - x32[ 8] = ~x32[ 8]; - x32[ 9] ^= 0xbfffffff^r; - x32[10] = ~x32[10]; - x32[11] ^= 0xafffffff^r; - x32[12] = ~x32[12]; - x32[13] ^= 0x9fffffff^r; - x32[14] = ~x32[14]; - x32[15] ^= 0x8fffffff^r; - COLUMN(x,y, 0, 2, 6, 10, 14, 1, 5, 9, 13, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 2, 4, 8, 12, 0, 3, 7, 11, 15, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 4, 6, 10, 14, 2, 5, 9, 13, 1, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 6, 8, 12, 0, 4, 7, 11, 15, 3, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y, 8, 10, 14, 2, 6, 9, 13, 1, 5, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,10, 12, 0, 4, 8, 11, 15, 3, 7, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,12, 14, 2, 6, 10, 13, 1, 5, 9, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); - COLUMN(x,y,14, 0, 4, 8, 12, 15, 3, 7, 11, temp_v1, temp_v2, temp_upper_value, temp_lower_value, temp); -} - -/* compute compression function (short variants) */ -static void F512(uint32_t *h, const uint32_t *m) { - int i; - uint32_t Ptmp[2*COLS512]; - uint32_t Qtmp[2*COLS512]; - uint32_t y[2*COLS512]; - uint32_t z[2*COLS512]; - - for (i = 0; i < 2*COLS512; i++) { - z[i] = m[i]; - Ptmp[i] = h[i]^m[i]; - } - - /* compute Q(m) */ - RND512Q((uint8_t*)z, y, 0x00000000); - RND512Q((uint8_t*)y, z, 0x01000000); - RND512Q((uint8_t*)z, y, 0x02000000); - RND512Q((uint8_t*)y, z, 0x03000000); - RND512Q((uint8_t*)z, y, 0x04000000); - RND512Q((uint8_t*)y, z, 0x05000000); - RND512Q((uint8_t*)z, y, 0x06000000); - RND512Q((uint8_t*)y, z, 0x07000000); - RND512Q((uint8_t*)z, y, 0x08000000); - RND512Q((uint8_t*)y, Qtmp, 0x09000000); - - /* compute P(h+m) */ - RND512P((uint8_t*)Ptmp, y, 0x00000000); - RND512P((uint8_t*)y, z, 0x00000001); - RND512P((uint8_t*)z, y, 0x00000002); - RND512P((uint8_t*)y, z, 0x00000003); - RND512P((uint8_t*)z, y, 0x00000004); - RND512P((uint8_t*)y, z, 0x00000005); - RND512P((uint8_t*)z, y, 0x00000006); - RND512P((uint8_t*)y, z, 0x00000007); - RND512P((uint8_t*)z, y, 0x00000008); - RND512P((uint8_t*)y, Ptmp, 0x00000009); - - /* compute P(h+m) + Q(m) + h */ - for (i = 0; i < 2*COLS512; i++) { - h[i] ^= Ptmp[i]^Qtmp[i]; - } -} - - -/* digest up to msglen bytes of input (full blocks only) */ -static void Transform(groestlHashState *ctx, - const uint8_t *input, - int msglen) { - - /* digest message, one block at a time */ - for (; msglen >= SIZE512; - msglen -= SIZE512, input += SIZE512) { - F512(ctx->chaining,(uint32_t*)input); - - /* increment block counter */ - ctx->block_counter1++; - if (ctx->block_counter1 == 0) ctx->block_counter2++; - } -} - -/* given state h, do h <- P(h)+h */ -static void OutputTransformation(groestlHashState *ctx) { - int j; - uint32_t temp[2*COLS512]; - uint32_t y[2*COLS512]; - uint32_t z[2*COLS512]; - - - - for (j = 0; j < 2*COLS512; j++) { - temp[j] = ctx->chaining[j]; - } - RND512P((uint8_t*)temp, y, 0x00000000); - RND512P((uint8_t*)y, z, 0x00000001); - RND512P((uint8_t*)z, y, 0x00000002); - RND512P((uint8_t*)y, z, 0x00000003); - RND512P((uint8_t*)z, y, 0x00000004); - RND512P((uint8_t*)y, z, 0x00000005); - RND512P((uint8_t*)z, y, 0x00000006); - RND512P((uint8_t*)y, z, 0x00000007); - RND512P((uint8_t*)z, y, 0x00000008); - RND512P((uint8_t*)y, temp, 0x00000009); - for (j = 0; j < 2*COLS512; j++) { - ctx->chaining[j] ^= temp[j]; - } -} - -/* initialise context */ -static void Init(groestlHashState* ctx) { - int i = 0; - /* allocate memory for state and data buffer */ - - for(;i<(SIZE512/sizeof(uint32_t));i++) - { - ctx->chaining[i] = 0; - } - - /* set initial value */ - ctx->chaining[2*COLS512-1] = u32BIG((uint32_t)HASH_BIT_LEN); - - /* set other variables */ - ctx->buf_ptr = 0; - ctx->block_counter1 = 0; - ctx->block_counter2 = 0; - ctx->bits_in_last_byte = 0; -} - -/* update state with databitlen bits of input */ -static void Update(groestlHashState* ctx, - const BitSequence* input, - DataLength databitlen) { - int index = 0; - int msglen = (int)(databitlen/8); - int rem = (int)(databitlen%8); - - /* if the buffer contains data that has not yet been digested, first - add data to buffer until full */ - if (ctx->buf_ptr) { - while (ctx->buf_ptr < SIZE512 && index < msglen) { - ctx->buffer[(int)ctx->buf_ptr++] = input[index++]; - } - if (ctx->buf_ptr < SIZE512) { - /* buffer still not full, return */ - if (rem) { - ctx->bits_in_last_byte = rem; - ctx->buffer[(int)ctx->buf_ptr++] = input[index]; - } - return; - } - - /* digest buffer */ - ctx->buf_ptr = 0; - Transform(ctx, ctx->buffer, SIZE512); - } - - /* digest bulk of message */ - Transform(ctx, input+index, msglen-index); - index += ((msglen-index)/SIZE512)*SIZE512; - - /* store remaining data in buffer */ - while (index < msglen) { - ctx->buffer[(int)ctx->buf_ptr++] = input[index++]; - } - - /* if non-integral number of bytes have been supplied, store - remaining bits in last byte, together with information about - number of bits */ - if (rem) { - ctx->bits_in_last_byte = rem; - ctx->buffer[(int)ctx->buf_ptr++] = input[index]; - } -} - -#define BILB ctx->bits_in_last_byte - -/* finalise: process remaining data (including padding), perform - output transformation, and write hash result to 'output' */ -static void Final(groestlHashState* ctx, - BitSequence* output) { - int i, j = 0, hashbytelen = HASH_BIT_LEN/8; - uint8_t *s = (BitSequence*)ctx->chaining; - - /* pad with '1'-bit and first few '0'-bits */ - if (BILB) { - ctx->buffer[(int)ctx->buf_ptr-1] &= ((1<buffer[(int)ctx->buf_ptr-1] ^= 0x1<<(7-BILB); - BILB = 0; - } - else ctx->buffer[(int)ctx->buf_ptr++] = 0x80; - - /* pad with '0'-bits */ - if (ctx->buf_ptr > SIZE512-LENGTHFIELDLEN) { - /* padding requires two blocks */ - while (ctx->buf_ptr < SIZE512) { - ctx->buffer[(int)ctx->buf_ptr++] = 0; - } - /* digest first padding block */ - Transform(ctx, ctx->buffer, SIZE512); - ctx->buf_ptr = 0; - } - while (ctx->buf_ptr < SIZE512-LENGTHFIELDLEN) { - ctx->buffer[(int)ctx->buf_ptr++] = 0; - } - - /* length padding */ - ctx->block_counter1++; - if (ctx->block_counter1 == 0) ctx->block_counter2++; - ctx->buf_ptr = SIZE512; - - while (ctx->buf_ptr > SIZE512-(int)sizeof(uint32_t)) { - ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter1; - ctx->block_counter1 >>= 8; - } - while (ctx->buf_ptr > SIZE512-LENGTHFIELDLEN) { - ctx->buffer[(int)--ctx->buf_ptr] = (uint8_t)ctx->block_counter2; - ctx->block_counter2 >>= 8; - } - /* digest final padding block */ - Transform(ctx, ctx->buffer, SIZE512); - /* perform output transformation */ - OutputTransformation(ctx); - - /* store hash result in output */ - for (i = SIZE512-hashbytelen; i < SIZE512; i++,j++) { - output[j] = s[i]; - } - - /* zeroise relevant variables and deallocate memory */ - for (i = 0; i < COLS512; i++) { - ctx->chaining[i] = 0; - } - for (i = 0; i < SIZE512; i++) { - ctx->buffer[i] = 0; - } -} - -/* hash bit sequence */ -void groestl(const BitSequence* data, - DataLength databitlen, - BitSequence* hashval) { - - groestlHashState context; - - /* initialise */ - Init(&context); - - - /* process message */ - Update(&context, data, databitlen); - - /* finalise */ - Final(&context, hashval); -} -/* -static int crypto_hash(unsigned char *out, - const unsigned char *in, - unsigned long long len) -{ - groestl(in, 8*len, out); - return 0; -} - -*/ diff --git a/src/Native/libcryptonight/xmrig/crypto/c_groestl.h b/src/Native/libcryptonight/xmrig/crypto/c_groestl.h deleted file mode 100644 index 2b51339340..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_groestl.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef __hash_h -#define __hash_h -/* -#include "crypto_uint8.h" -#include "crypto_uint32.h" -#include "crypto_uint64.h" -#include "crypto_hash.h" - -typedef crypto_uint8 uint8_t; -typedef crypto_uint32 uint32_t; -typedef crypto_uint64 uint64_t; -*/ -#include - -#include "hash.h" - -/* some sizes (number of bytes) */ -#define ROWS 8 -#define LENGTHFIELDLEN ROWS -#define COLS512 8 - -#define SIZE512 (ROWS*COLS512) - -#define ROUNDS512 10 -#define HASH_BIT_LEN 256 - -#define ROTL32(v, n) ((((v)<<(n))|((v)>>(32-(n))))&li_32(ffffffff)) - - -#define li_32(h) 0x##h##u -#define EXT_BYTE(var,n) ((uint8_t)((uint32_t)(var) >> (8*n))) -#define u32BIG(a) \ - ((ROTL32(a,8) & li_32(00FF00FF)) | \ - (ROTL32(a,24) & li_32(FF00FF00))) - - -/* NIST API begin */ -typedef struct { - uint32_t chaining[SIZE512/sizeof(uint32_t)]; /* actual state */ - uint32_t block_counter1, - block_counter2; /* message block counter(s) */ - BitSequence buffer[SIZE512]; /* data buffer */ - int buf_ptr; /* data buffer pointer */ - int bits_in_last_byte; /* no. of message bits in last byte of - data buffer */ -} groestlHashState; - -/*void Init(hashState*); -void Update(hashState*, const BitSequence*, DataLength); -void Final(hashState*, BitSequence*); */ -void groestl(const BitSequence*, DataLength, BitSequence*); -/* NIST API end */ - -/* -int crypto_hash(unsigned char *out, - const unsigned char *in, - unsigned long long len); -*/ - -#endif /* __hash_h */ diff --git a/src/Native/libcryptonight/xmrig/crypto/c_jh.c b/src/Native/libcryptonight/xmrig/crypto/c_jh.c deleted file mode 100644 index 728f3bbee8..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_jh.c +++ /dev/null @@ -1,367 +0,0 @@ -/*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C - - -------------------------------- - Performance - - Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) - Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) - Speed for long message: - 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 - 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 - - -------------------------------- - Last Modified: January 16, 2011 -*/ - -#include "c_jh.h" - -#include -#include - -/*typedef unsigned long long uint64;*/ -typedef uint64_t uint64; - -/*define data alignment for different C compilers*/ -#if defined(__GNUC__) - #define DATA_ALIGN16(x) x __attribute__ ((aligned(16))) -#else - #define DATA_ALIGN16(x) __declspec(align(16)) x -#endif - - -typedef struct { - int hashbitlen; /*the message digest size*/ - unsigned long long databitlen; /*the message size in bits*/ - unsigned long long datasize_in_buffer; /*the size of the message remained in buffer; assumed to be multiple of 8bits except for the last partial block at the end of the message*/ - DATA_ALIGN16(uint64 x[8][2]); /*the 1024-bit state, ( x[i][0] || x[i][1] ) is the ith row of the state in the pseudocode*/ - unsigned char buffer[64]; /*the 512-bit message block to be hashed;*/ -} hashState; - - -/*The initial hash value H(0)*/ -const unsigned char JH224_H0[128]={0x2d,0xfe,0xdd,0x62,0xf9,0x9a,0x98,0xac,0xae,0x7c,0xac,0xd6,0x19,0xd6,0x34,0xe7,0xa4,0x83,0x10,0x5,0xbc,0x30,0x12,0x16,0xb8,0x60,0x38,0xc6,0xc9,0x66,0x14,0x94,0x66,0xd9,0x89,0x9f,0x25,0x80,0x70,0x6f,0xce,0x9e,0xa3,0x1b,0x1d,0x9b,0x1a,0xdc,0x11,0xe8,0x32,0x5f,0x7b,0x36,0x6e,0x10,0xf9,0x94,0x85,0x7f,0x2,0xfa,0x6,0xc1,0x1b,0x4f,0x1b,0x5c,0xd8,0xc8,0x40,0xb3,0x97,0xf6,0xa1,0x7f,0x6e,0x73,0x80,0x99,0xdc,0xdf,0x93,0xa5,0xad,0xea,0xa3,0xd3,0xa4,0x31,0xe8,0xde,0xc9,0x53,0x9a,0x68,0x22,0xb4,0xa9,0x8a,0xec,0x86,0xa1,0xe4,0xd5,0x74,0xac,0x95,0x9c,0xe5,0x6c,0xf0,0x15,0x96,0xd,0xea,0xb5,0xab,0x2b,0xbf,0x96,0x11,0xdc,0xf0,0xdd,0x64,0xea,0x6e}; -const unsigned char JH256_H0[128]={0xeb,0x98,0xa3,0x41,0x2c,0x20,0xd3,0xeb,0x92,0xcd,0xbe,0x7b,0x9c,0xb2,0x45,0xc1,0x1c,0x93,0x51,0x91,0x60,0xd4,0xc7,0xfa,0x26,0x0,0x82,0xd6,0x7e,0x50,0x8a,0x3,0xa4,0x23,0x9e,0x26,0x77,0x26,0xb9,0x45,0xe0,0xfb,0x1a,0x48,0xd4,0x1a,0x94,0x77,0xcd,0xb5,0xab,0x26,0x2,0x6b,0x17,0x7a,0x56,0xf0,0x24,0x42,0xf,0xff,0x2f,0xa8,0x71,0xa3,0x96,0x89,0x7f,0x2e,0x4d,0x75,0x1d,0x14,0x49,0x8,0xf7,0x7d,0xe2,0x62,0x27,0x76,0x95,0xf7,0x76,0x24,0x8f,0x94,0x87,0xd5,0xb6,0x57,0x47,0x80,0x29,0x6c,0x5c,0x5e,0x27,0x2d,0xac,0x8e,0xd,0x6c,0x51,0x84,0x50,0xc6,0x57,0x5,0x7a,0xf,0x7b,0xe4,0xd3,0x67,0x70,0x24,0x12,0xea,0x89,0xe3,0xab,0x13,0xd3,0x1c,0xd7,0x69}; -const unsigned char JH384_H0[128]={0x48,0x1e,0x3b,0xc6,0xd8,0x13,0x39,0x8a,0x6d,0x3b,0x5e,0x89,0x4a,0xde,0x87,0x9b,0x63,0xfa,0xea,0x68,0xd4,0x80,0xad,0x2e,0x33,0x2c,0xcb,0x21,0x48,0xf,0x82,0x67,0x98,0xae,0xc8,0x4d,0x90,0x82,0xb9,0x28,0xd4,0x55,0xea,0x30,0x41,0x11,0x42,0x49,0x36,0xf5,0x55,0xb2,0x92,0x48,0x47,0xec,0xc7,0x25,0xa,0x93,0xba,0xf4,0x3c,0xe1,0x56,0x9b,0x7f,0x8a,0x27,0xdb,0x45,0x4c,0x9e,0xfc,0xbd,0x49,0x63,0x97,0xaf,0xe,0x58,0x9f,0xc2,0x7d,0x26,0xaa,0x80,0xcd,0x80,0xc0,0x8b,0x8c,0x9d,0xeb,0x2e,0xda,0x8a,0x79,0x81,0xe8,0xf8,0xd5,0x37,0x3a,0xf4,0x39,0x67,0xad,0xdd,0xd1,0x7a,0x71,0xa9,0xb4,0xd3,0xbd,0xa4,0x75,0xd3,0x94,0x97,0x6c,0x3f,0xba,0x98,0x42,0x73,0x7f}; -const unsigned char JH512_H0[128]={0x6f,0xd1,0x4b,0x96,0x3e,0x0,0xaa,0x17,0x63,0x6a,0x2e,0x5,0x7a,0x15,0xd5,0x43,0x8a,0x22,0x5e,0x8d,0xc,0x97,0xef,0xb,0xe9,0x34,0x12,0x59,0xf2,0xb3,0xc3,0x61,0x89,0x1d,0xa0,0xc1,0x53,0x6f,0x80,0x1e,0x2a,0xa9,0x5,0x6b,0xea,0x2b,0x6d,0x80,0x58,0x8e,0xcc,0xdb,0x20,0x75,0xba,0xa6,0xa9,0xf,0x3a,0x76,0xba,0xf8,0x3b,0xf7,0x1,0x69,0xe6,0x5,0x41,0xe3,0x4a,0x69,0x46,0xb5,0x8a,0x8e,0x2e,0x6f,0xe6,0x5a,0x10,0x47,0xa7,0xd0,0xc1,0x84,0x3c,0x24,0x3b,0x6e,0x71,0xb1,0x2d,0x5a,0xc1,0x99,0xcf,0x57,0xf6,0xec,0x9d,0xb1,0xf8,0x56,0xa7,0x6,0x88,0x7c,0x57,0x16,0xb1,0x56,0xe3,0xc2,0xfc,0xdf,0xe6,0x85,0x17,0xfb,0x54,0x5a,0x46,0x78,0xcc,0x8c,0xdd,0x4b}; - -/*42 round constants, each round constant is 32-byte (256-bit)*/ -const unsigned char E8_bitslice_roundconstant[42][32]={ -{0x72,0xd5,0xde,0xa2,0xdf,0x15,0xf8,0x67,0x7b,0x84,0x15,0xa,0xb7,0x23,0x15,0x57,0x81,0xab,0xd6,0x90,0x4d,0x5a,0x87,0xf6,0x4e,0x9f,0x4f,0xc5,0xc3,0xd1,0x2b,0x40}, -{0xea,0x98,0x3a,0xe0,0x5c,0x45,0xfa,0x9c,0x3,0xc5,0xd2,0x99,0x66,0xb2,0x99,0x9a,0x66,0x2,0x96,0xb4,0xf2,0xbb,0x53,0x8a,0xb5,0x56,0x14,0x1a,0x88,0xdb,0xa2,0x31}, -{0x3,0xa3,0x5a,0x5c,0x9a,0x19,0xe,0xdb,0x40,0x3f,0xb2,0xa,0x87,0xc1,0x44,0x10,0x1c,0x5,0x19,0x80,0x84,0x9e,0x95,0x1d,0x6f,0x33,0xeb,0xad,0x5e,0xe7,0xcd,0xdc}, -{0x10,0xba,0x13,0x92,0x2,0xbf,0x6b,0x41,0xdc,0x78,0x65,0x15,0xf7,0xbb,0x27,0xd0,0xa,0x2c,0x81,0x39,0x37,0xaa,0x78,0x50,0x3f,0x1a,0xbf,0xd2,0x41,0x0,0x91,0xd3}, -{0x42,0x2d,0x5a,0xd,0xf6,0xcc,0x7e,0x90,0xdd,0x62,0x9f,0x9c,0x92,0xc0,0x97,0xce,0x18,0x5c,0xa7,0xb,0xc7,0x2b,0x44,0xac,0xd1,0xdf,0x65,0xd6,0x63,0xc6,0xfc,0x23}, -{0x97,0x6e,0x6c,0x3,0x9e,0xe0,0xb8,0x1a,0x21,0x5,0x45,0x7e,0x44,0x6c,0xec,0xa8,0xee,0xf1,0x3,0xbb,0x5d,0x8e,0x61,0xfa,0xfd,0x96,0x97,0xb2,0x94,0x83,0x81,0x97}, -{0x4a,0x8e,0x85,0x37,0xdb,0x3,0x30,0x2f,0x2a,0x67,0x8d,0x2d,0xfb,0x9f,0x6a,0x95,0x8a,0xfe,0x73,0x81,0xf8,0xb8,0x69,0x6c,0x8a,0xc7,0x72,0x46,0xc0,0x7f,0x42,0x14}, -{0xc5,0xf4,0x15,0x8f,0xbd,0xc7,0x5e,0xc4,0x75,0x44,0x6f,0xa7,0x8f,0x11,0xbb,0x80,0x52,0xde,0x75,0xb7,0xae,0xe4,0x88,0xbc,0x82,0xb8,0x0,0x1e,0x98,0xa6,0xa3,0xf4}, -{0x8e,0xf4,0x8f,0x33,0xa9,0xa3,0x63,0x15,0xaa,0x5f,0x56,0x24,0xd5,0xb7,0xf9,0x89,0xb6,0xf1,0xed,0x20,0x7c,0x5a,0xe0,0xfd,0x36,0xca,0xe9,0x5a,0x6,0x42,0x2c,0x36}, -{0xce,0x29,0x35,0x43,0x4e,0xfe,0x98,0x3d,0x53,0x3a,0xf9,0x74,0x73,0x9a,0x4b,0xa7,0xd0,0xf5,0x1f,0x59,0x6f,0x4e,0x81,0x86,0xe,0x9d,0xad,0x81,0xaf,0xd8,0x5a,0x9f}, -{0xa7,0x5,0x6,0x67,0xee,0x34,0x62,0x6a,0x8b,0xb,0x28,0xbe,0x6e,0xb9,0x17,0x27,0x47,0x74,0x7,0x26,0xc6,0x80,0x10,0x3f,0xe0,0xa0,0x7e,0x6f,0xc6,0x7e,0x48,0x7b}, -{0xd,0x55,0xa,0xa5,0x4a,0xf8,0xa4,0xc0,0x91,0xe3,0xe7,0x9f,0x97,0x8e,0xf1,0x9e,0x86,0x76,0x72,0x81,0x50,0x60,0x8d,0xd4,0x7e,0x9e,0x5a,0x41,0xf3,0xe5,0xb0,0x62}, -{0xfc,0x9f,0x1f,0xec,0x40,0x54,0x20,0x7a,0xe3,0xe4,0x1a,0x0,0xce,0xf4,0xc9,0x84,0x4f,0xd7,0x94,0xf5,0x9d,0xfa,0x95,0xd8,0x55,0x2e,0x7e,0x11,0x24,0xc3,0x54,0xa5}, -{0x5b,0xdf,0x72,0x28,0xbd,0xfe,0x6e,0x28,0x78,0xf5,0x7f,0xe2,0xf,0xa5,0xc4,0xb2,0x5,0x89,0x7c,0xef,0xee,0x49,0xd3,0x2e,0x44,0x7e,0x93,0x85,0xeb,0x28,0x59,0x7f}, -{0x70,0x5f,0x69,0x37,0xb3,0x24,0x31,0x4a,0x5e,0x86,0x28,0xf1,0x1d,0xd6,0xe4,0x65,0xc7,0x1b,0x77,0x4,0x51,0xb9,0x20,0xe7,0x74,0xfe,0x43,0xe8,0x23,0xd4,0x87,0x8a}, -{0x7d,0x29,0xe8,0xa3,0x92,0x76,0x94,0xf2,0xdd,0xcb,0x7a,0x9,0x9b,0x30,0xd9,0xc1,0x1d,0x1b,0x30,0xfb,0x5b,0xdc,0x1b,0xe0,0xda,0x24,0x49,0x4f,0xf2,0x9c,0x82,0xbf}, -{0xa4,0xe7,0xba,0x31,0xb4,0x70,0xbf,0xff,0xd,0x32,0x44,0x5,0xde,0xf8,0xbc,0x48,0x3b,0xae,0xfc,0x32,0x53,0xbb,0xd3,0x39,0x45,0x9f,0xc3,0xc1,0xe0,0x29,0x8b,0xa0}, -{0xe5,0xc9,0x5,0xfd,0xf7,0xae,0x9,0xf,0x94,0x70,0x34,0x12,0x42,0x90,0xf1,0x34,0xa2,0x71,0xb7,0x1,0xe3,0x44,0xed,0x95,0xe9,0x3b,0x8e,0x36,0x4f,0x2f,0x98,0x4a}, -{0x88,0x40,0x1d,0x63,0xa0,0x6c,0xf6,0x15,0x47,0xc1,0x44,0x4b,0x87,0x52,0xaf,0xff,0x7e,0xbb,0x4a,0xf1,0xe2,0xa,0xc6,0x30,0x46,0x70,0xb6,0xc5,0xcc,0x6e,0x8c,0xe6}, -{0xa4,0xd5,0xa4,0x56,0xbd,0x4f,0xca,0x0,0xda,0x9d,0x84,0x4b,0xc8,0x3e,0x18,0xae,0x73,0x57,0xce,0x45,0x30,0x64,0xd1,0xad,0xe8,0xa6,0xce,0x68,0x14,0x5c,0x25,0x67}, -{0xa3,0xda,0x8c,0xf2,0xcb,0xe,0xe1,0x16,0x33,0xe9,0x6,0x58,0x9a,0x94,0x99,0x9a,0x1f,0x60,0xb2,0x20,0xc2,0x6f,0x84,0x7b,0xd1,0xce,0xac,0x7f,0xa0,0xd1,0x85,0x18}, -{0x32,0x59,0x5b,0xa1,0x8d,0xdd,0x19,0xd3,0x50,0x9a,0x1c,0xc0,0xaa,0xa5,0xb4,0x46,0x9f,0x3d,0x63,0x67,0xe4,0x4,0x6b,0xba,0xf6,0xca,0x19,0xab,0xb,0x56,0xee,0x7e}, -{0x1f,0xb1,0x79,0xea,0xa9,0x28,0x21,0x74,0xe9,0xbd,0xf7,0x35,0x3b,0x36,0x51,0xee,0x1d,0x57,0xac,0x5a,0x75,0x50,0xd3,0x76,0x3a,0x46,0xc2,0xfe,0xa3,0x7d,0x70,0x1}, -{0xf7,0x35,0xc1,0xaf,0x98,0xa4,0xd8,0x42,0x78,0xed,0xec,0x20,0x9e,0x6b,0x67,0x79,0x41,0x83,0x63,0x15,0xea,0x3a,0xdb,0xa8,0xfa,0xc3,0x3b,0x4d,0x32,0x83,0x2c,0x83}, -{0xa7,0x40,0x3b,0x1f,0x1c,0x27,0x47,0xf3,0x59,0x40,0xf0,0x34,0xb7,0x2d,0x76,0x9a,0xe7,0x3e,0x4e,0x6c,0xd2,0x21,0x4f,0xfd,0xb8,0xfd,0x8d,0x39,0xdc,0x57,0x59,0xef}, -{0x8d,0x9b,0xc,0x49,0x2b,0x49,0xeb,0xda,0x5b,0xa2,0xd7,0x49,0x68,0xf3,0x70,0xd,0x7d,0x3b,0xae,0xd0,0x7a,0x8d,0x55,0x84,0xf5,0xa5,0xe9,0xf0,0xe4,0xf8,0x8e,0x65}, -{0xa0,0xb8,0xa2,0xf4,0x36,0x10,0x3b,0x53,0xc,0xa8,0x7,0x9e,0x75,0x3e,0xec,0x5a,0x91,0x68,0x94,0x92,0x56,0xe8,0x88,0x4f,0x5b,0xb0,0x5c,0x55,0xf8,0xba,0xbc,0x4c}, -{0xe3,0xbb,0x3b,0x99,0xf3,0x87,0x94,0x7b,0x75,0xda,0xf4,0xd6,0x72,0x6b,0x1c,0x5d,0x64,0xae,0xac,0x28,0xdc,0x34,0xb3,0x6d,0x6c,0x34,0xa5,0x50,0xb8,0x28,0xdb,0x71}, -{0xf8,0x61,0xe2,0xf2,0x10,0x8d,0x51,0x2a,0xe3,0xdb,0x64,0x33,0x59,0xdd,0x75,0xfc,0x1c,0xac,0xbc,0xf1,0x43,0xce,0x3f,0xa2,0x67,0xbb,0xd1,0x3c,0x2,0xe8,0x43,0xb0}, -{0x33,0xa,0x5b,0xca,0x88,0x29,0xa1,0x75,0x7f,0x34,0x19,0x4d,0xb4,0x16,0x53,0x5c,0x92,0x3b,0x94,0xc3,0xe,0x79,0x4d,0x1e,0x79,0x74,0x75,0xd7,0xb6,0xee,0xaf,0x3f}, -{0xea,0xa8,0xd4,0xf7,0xbe,0x1a,0x39,0x21,0x5c,0xf4,0x7e,0x9,0x4c,0x23,0x27,0x51,0x26,0xa3,0x24,0x53,0xba,0x32,0x3c,0xd2,0x44,0xa3,0x17,0x4a,0x6d,0xa6,0xd5,0xad}, -{0xb5,0x1d,0x3e,0xa6,0xaf,0xf2,0xc9,0x8,0x83,0x59,0x3d,0x98,0x91,0x6b,0x3c,0x56,0x4c,0xf8,0x7c,0xa1,0x72,0x86,0x60,0x4d,0x46,0xe2,0x3e,0xcc,0x8,0x6e,0xc7,0xf6}, -{0x2f,0x98,0x33,0xb3,0xb1,0xbc,0x76,0x5e,0x2b,0xd6,0x66,0xa5,0xef,0xc4,0xe6,0x2a,0x6,0xf4,0xb6,0xe8,0xbe,0xc1,0xd4,0x36,0x74,0xee,0x82,0x15,0xbc,0xef,0x21,0x63}, -{0xfd,0xc1,0x4e,0xd,0xf4,0x53,0xc9,0x69,0xa7,0x7d,0x5a,0xc4,0x6,0x58,0x58,0x26,0x7e,0xc1,0x14,0x16,0x6,0xe0,0xfa,0x16,0x7e,0x90,0xaf,0x3d,0x28,0x63,0x9d,0x3f}, -{0xd2,0xc9,0xf2,0xe3,0x0,0x9b,0xd2,0xc,0x5f,0xaa,0xce,0x30,0xb7,0xd4,0xc,0x30,0x74,0x2a,0x51,0x16,0xf2,0xe0,0x32,0x98,0xd,0xeb,0x30,0xd8,0xe3,0xce,0xf8,0x9a}, -{0x4b,0xc5,0x9e,0x7b,0xb5,0xf1,0x79,0x92,0xff,0x51,0xe6,0x6e,0x4,0x86,0x68,0xd3,0x9b,0x23,0x4d,0x57,0xe6,0x96,0x67,0x31,0xcc,0xe6,0xa6,0xf3,0x17,0xa,0x75,0x5}, -{0xb1,0x76,0x81,0xd9,0x13,0x32,0x6c,0xce,0x3c,0x17,0x52,0x84,0xf8,0x5,0xa2,0x62,0xf4,0x2b,0xcb,0xb3,0x78,0x47,0x15,0x47,0xff,0x46,0x54,0x82,0x23,0x93,0x6a,0x48}, -{0x38,0xdf,0x58,0x7,0x4e,0x5e,0x65,0x65,0xf2,0xfc,0x7c,0x89,0xfc,0x86,0x50,0x8e,0x31,0x70,0x2e,0x44,0xd0,0xb,0xca,0x86,0xf0,0x40,0x9,0xa2,0x30,0x78,0x47,0x4e}, -{0x65,0xa0,0xee,0x39,0xd1,0xf7,0x38,0x83,0xf7,0x5e,0xe9,0x37,0xe4,0x2c,0x3a,0xbd,0x21,0x97,0xb2,0x26,0x1,0x13,0xf8,0x6f,0xa3,0x44,0xed,0xd1,0xef,0x9f,0xde,0xe7}, -{0x8b,0xa0,0xdf,0x15,0x76,0x25,0x92,0xd9,0x3c,0x85,0xf7,0xf6,0x12,0xdc,0x42,0xbe,0xd8,0xa7,0xec,0x7c,0xab,0x27,0xb0,0x7e,0x53,0x8d,0x7d,0xda,0xaa,0x3e,0xa8,0xde}, -{0xaa,0x25,0xce,0x93,0xbd,0x2,0x69,0xd8,0x5a,0xf6,0x43,0xfd,0x1a,0x73,0x8,0xf9,0xc0,0x5f,0xef,0xda,0x17,0x4a,0x19,0xa5,0x97,0x4d,0x66,0x33,0x4c,0xfd,0x21,0x6a}, -{0x35,0xb4,0x98,0x31,0xdb,0x41,0x15,0x70,0xea,0x1e,0xf,0xbb,0xed,0xcd,0x54,0x9b,0x9a,0xd0,0x63,0xa1,0x51,0x97,0x40,0x72,0xf6,0x75,0x9d,0xbf,0x91,0x47,0x6f,0xe2}}; - - -static void E8(hashState *state); /*The bijective function E8, in bitslice form*/ -static void F8(hashState *state); /*The compression function F8 */ - -/*The API functions*/ -static HashReturn Init(hashState *state, int hashbitlen); -static HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen); -static HashReturn Final(hashState *state, BitSequence *hashval); -HashReturn jh_hash(int hashbitlen, const BitSequence *data,DataLength databitlen, BitSequence *hashval); - -/*swapping bit 2i with bit 2i+1 of 64-bit x*/ -#define SWAP1(x) (x) = ((((x) & 0x5555555555555555ULL) << 1) | (((x) & 0xaaaaaaaaaaaaaaaaULL) >> 1)); -/*swapping bits 4i||4i+1 with bits 4i+2||4i+3 of 64-bit x*/ -#define SWAP2(x) (x) = ((((x) & 0x3333333333333333ULL) << 2) | (((x) & 0xccccccccccccccccULL) >> 2)); -/*swapping bits 8i||8i+1||8i+2||8i+3 with bits 8i+4||8i+5||8i+6||8i+7 of 64-bit x*/ -#define SWAP4(x) (x) = ((((x) & 0x0f0f0f0f0f0f0f0fULL) << 4) | (((x) & 0xf0f0f0f0f0f0f0f0ULL) >> 4)); -/*swapping bits 16i||16i+1||......||16i+7 with bits 16i+8||16i+9||......||16i+15 of 64-bit x*/ -#define SWAP8(x) (x) = ((((x) & 0x00ff00ff00ff00ffULL) << 8) | (((x) & 0xff00ff00ff00ff00ULL) >> 8)); -/*swapping bits 32i||32i+1||......||32i+15 with bits 32i+16||32i+17||......||32i+31 of 64-bit x*/ -#define SWAP16(x) (x) = ((((x) & 0x0000ffff0000ffffULL) << 16) | (((x) & 0xffff0000ffff0000ULL) >> 16)); -/*swapping bits 64i||64i+1||......||64i+31 with bits 64i+32||64i+33||......||64i+63 of 64-bit x*/ -#define SWAP32(x) (x) = (((x) << 32) | ((x) >> 32)); - -/*The MDS transform*/ -#define L(m0,m1,m2,m3,m4,m5,m6,m7) \ - (m4) ^= (m1); \ - (m5) ^= (m2); \ - (m6) ^= (m0) ^ (m3); \ - (m7) ^= (m0); \ - (m0) ^= (m5); \ - (m1) ^= (m6); \ - (m2) ^= (m4) ^ (m7); \ - (m3) ^= (m4); - -/*Two Sboxes are computed in parallel, each Sbox implements S0 and S1, selected by a constant bit*/ -/*The reason to compute two Sboxes in parallel is to try to fully utilize the parallel processing power*/ -#define SS(m0,m1,m2,m3,m4,m5,m6,m7,cc0,cc1) \ - m3 = ~(m3); \ - m7 = ~(m7); \ - m0 ^= ((~(m2)) & (cc0)); \ - m4 ^= ((~(m6)) & (cc1)); \ - temp0 = (cc0) ^ ((m0) & (m1));\ - temp1 = (cc1) ^ ((m4) & (m5));\ - m0 ^= ((m2) & (m3)); \ - m4 ^= ((m6) & (m7)); \ - m3 ^= ((~(m1)) & (m2)); \ - m7 ^= ((~(m5)) & (m6)); \ - m1 ^= ((m0) & (m2)); \ - m5 ^= ((m4) & (m6)); \ - m2 ^= ((m0) & (~(m3))); \ - m6 ^= ((m4) & (~(m7))); \ - m0 ^= ((m1) | (m3)); \ - m4 ^= ((m5) | (m7)); \ - m3 ^= ((m1) & (m2)); \ - m7 ^= ((m5) & (m6)); \ - m1 ^= (temp0 & (m0)); \ - m5 ^= (temp1 & (m4)); \ - m2 ^= temp0; \ - m6 ^= temp1; - -/*The bijective function E8, in bitslice form*/ -static void E8(hashState *state) -{ - uint64 i,roundnumber,temp0,temp1; - - for (roundnumber = 0; roundnumber < 42; roundnumber = roundnumber+7) { - /*round 7*roundnumber+0: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+0])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+0])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP1(state->x[1][i]); SWAP1(state->x[3][i]); SWAP1(state->x[5][i]); SWAP1(state->x[7][i]); - } - - /*round 7*roundnumber+1: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+1])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+1])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP2(state->x[1][i]); SWAP2(state->x[3][i]); SWAP2(state->x[5][i]); SWAP2(state->x[7][i]); - } - - /*round 7*roundnumber+2: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+2])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+2])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP4(state->x[1][i]); SWAP4(state->x[3][i]); SWAP4(state->x[5][i]); SWAP4(state->x[7][i]); - } - - /*round 7*roundnumber+3: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+3])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+3])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP8(state->x[1][i]); SWAP8(state->x[3][i]); SWAP8(state->x[5][i]); SWAP8(state->x[7][i]); - } - - /*round 7*roundnumber+4: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+4])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+4])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP16(state->x[1][i]); SWAP16(state->x[3][i]); SWAP16(state->x[5][i]); SWAP16(state->x[7][i]); - } - - /*round 7*roundnumber+5: Sbox, MDS and Swapping layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+5])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+5])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - SWAP32(state->x[1][i]); SWAP32(state->x[3][i]); SWAP32(state->x[5][i]); SWAP32(state->x[7][i]); - } - - /*round 7*roundnumber+6: Sbox and MDS layers*/ - for (i = 0; i < 2; i++) { - SS(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i],((uint64*)E8_bitslice_roundconstant[roundnumber+6])[i],((uint64*)E8_bitslice_roundconstant[roundnumber+6])[i+2] ); - L(state->x[0][i],state->x[2][i],state->x[4][i],state->x[6][i],state->x[1][i],state->x[3][i],state->x[5][i],state->x[7][i]); - } - /*round 7*roundnumber+6: swapping layer*/ - for (i = 1; i < 8; i = i+2) { - temp0 = state->x[i][0]; state->x[i][0] = state->x[i][1]; state->x[i][1] = temp0; - } - } - -} - -/*The compression function F8 */ -static void F8(hashState *state) -{ - uint64 i; - - /*xor the 512-bit message with the fist half of the 1024-bit hash state*/ - for (i = 0; i < 8; i++) state->x[i >> 1][i & 1] ^= ((uint64*)state->buffer)[i]; - - /*the bijective function E8 */ - E8(state); - - /*xor the 512-bit message with the second half of the 1024-bit hash state*/ - for (i = 0; i < 8; i++) state->x[(8+i) >> 1][(8+i) & 1] ^= ((uint64*)state->buffer)[i]; -} - -/*before hashing a message, initialize the hash state as H0 */ -static HashReturn Init(hashState *state, int hashbitlen) -{ - state->databitlen = 0; - state->datasize_in_buffer = 0; - - /*initialize the initial hash value of JH*/ - state->hashbitlen = hashbitlen; - - /*load the intital hash value into state*/ - switch (hashbitlen) - { - case 224: memcpy(state->x,JH224_H0,128); break; - case 256: memcpy(state->x,JH256_H0,128); break; - case 384: memcpy(state->x,JH384_H0,128); break; - case 512: memcpy(state->x,JH512_H0,128); break; - } - - return(SUCCESS); -} - - -/*hash each 512-bit message block, except the last partial block*/ -static HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen) -{ - DataLength index; /*the starting address of the data to be compressed*/ - - state->databitlen += databitlen; - index = 0; - - /*if there is remaining data in the buffer, fill it to a full message block first*/ - /*we assume that the size of the data in the buffer is the multiple of 8 bits if it is not at the end of a message*/ - - /*There is data in the buffer, but the incoming data is insufficient for a full block*/ - if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) < 512) ) { - if ( (databitlen & 7) == 0 ) { - memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3)) ; - } - else memcpy(state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3)+1) ; - state->datasize_in_buffer += databitlen; - databitlen = 0; - } - - /*There is data in the buffer, and the incoming data is sufficient for a full block*/ - if ( (state->datasize_in_buffer > 0 ) && (( state->datasize_in_buffer + databitlen) >= 512) ) { - memcpy( state->buffer + (state->datasize_in_buffer >> 3), data, 64-(state->datasize_in_buffer >> 3) ) ; - index = 64-(state->datasize_in_buffer >> 3); - databitlen = databitlen - (512 - state->datasize_in_buffer); - F8(state); - state->datasize_in_buffer = 0; - } - - /*hash the remaining full message blocks*/ - for ( ; databitlen >= 512; index = index+64, databitlen = databitlen - 512) { - memcpy(state->buffer, data+index, 64); - F8(state); - } - - /*store the partial block into buffer, assume that -- if part of the last byte is not part of the message, then that part consists of 0 bits*/ - if ( databitlen > 0) { - if ((databitlen & 7) == 0) - memcpy(state->buffer, data+index, (databitlen & 0x1ff) >> 3); - else - memcpy(state->buffer, data+index, ((databitlen & 0x1ff) >> 3)+1); - state->datasize_in_buffer = databitlen; - } - - return(SUCCESS); -} - -/*pad the message, process the padded block(s), truncate the hash value H to obtain the message digest*/ -static HashReturn Final(hashState *state, BitSequence *hashval) -{ - unsigned int i; - - if ( (state->databitlen & 0x1ff) == 0 ) { - /*pad the message when databitlen is multiple of 512 bits, then process the padded block*/ - memset(state->buffer, 0, 64); - state->buffer[0] = 0x80; - state->buffer[63] = state->databitlen & 0xff; - state->buffer[62] = (state->databitlen >> 8) & 0xff; - state->buffer[61] = (state->databitlen >> 16) & 0xff; - state->buffer[60] = (state->databitlen >> 24) & 0xff; - state->buffer[59] = (state->databitlen >> 32) & 0xff; - state->buffer[58] = (state->databitlen >> 40) & 0xff; - state->buffer[57] = (state->databitlen >> 48) & 0xff; - state->buffer[56] = (state->databitlen >> 56) & 0xff; - F8(state); - } - else { - /*set the rest of the bytes in the buffer to 0*/ - if ( (state->datasize_in_buffer & 7) == 0) - for (i = (state->databitlen & 0x1ff) >> 3; i < 64; i++) state->buffer[i] = 0; - else - for (i = ((state->databitlen & 0x1ff) >> 3)+1; i < 64; i++) state->buffer[i] = 0; - - /*pad and process the partial block when databitlen is not multiple of 512 bits, then hash the padded blocks*/ - state->buffer[((state->databitlen & 0x1ff) >> 3)] |= 1 << (7- (state->databitlen & 7)); - - F8(state); - memset(state->buffer, 0, 64); - state->buffer[63] = state->databitlen & 0xff; - state->buffer[62] = (state->databitlen >> 8) & 0xff; - state->buffer[61] = (state->databitlen >> 16) & 0xff; - state->buffer[60] = (state->databitlen >> 24) & 0xff; - state->buffer[59] = (state->databitlen >> 32) & 0xff; - state->buffer[58] = (state->databitlen >> 40) & 0xff; - state->buffer[57] = (state->databitlen >> 48) & 0xff; - state->buffer[56] = (state->databitlen >> 56) & 0xff; - F8(state); - } - - /*truncating the final hash value to generate the message digest*/ - switch(state->hashbitlen) { - case 224: memcpy(hashval,(unsigned char*)state->x+64+36,28); break; - case 256: memcpy(hashval,(unsigned char*)state->x+64+32,32); break; - case 384: memcpy(hashval,(unsigned char*)state->x+64+16,48); break; - case 512: memcpy(hashval,(unsigned char*)state->x+64,64); break; - } - - return(SUCCESS); -} - -/* hash a message, - three inputs: message digest size in bits (hashbitlen); message (data); message length in bits (databitlen) - one output: message digest (hashval) -*/ -HashReturn jh_hash(int hashbitlen, const BitSequence *data,DataLength databitlen, BitSequence *hashval) -{ - hashState state; - - if ( hashbitlen == 224 || hashbitlen == 256 || hashbitlen == 384 || hashbitlen == 512 ) { - Init(&state, hashbitlen); - Update(&state, data, databitlen); - Final(&state, hashval); - return SUCCESS; - } - else - return(BAD_HASHLEN); -} diff --git a/src/Native/libcryptonight/xmrig/crypto/c_jh.h b/src/Native/libcryptonight/xmrig/crypto/c_jh.h deleted file mode 100644 index d10d40fe57..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_jh.h +++ /dev/null @@ -1,19 +0,0 @@ -/*This program gives the 64-bit optimized bitslice implementation of JH using ANSI C - - -------------------------------- - Performance - - Microprocessor: Intel CORE 2 processor (Core 2 Duo Mobile T6600 2.2GHz) - Operating System: 64-bit Ubuntu 10.04 (Linux kernel 2.6.32-22-generic) - Speed for long message: - 1) 45.8 cycles/byte compiler: Intel C++ Compiler 11.1 compilation option: icc -O2 - 2) 56.8 cycles/byte compiler: gcc 4.4.3 compilation option: gcc -O3 - - -------------------------------- - Last Modified: January 16, 2011 -*/ -#pragma once - -#include "hash.h" - -HashReturn jh_hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval); diff --git a/src/Native/libcryptonight/xmrig/crypto/c_skein.c b/src/Native/libcryptonight/xmrig/crypto/c_skein.c deleted file mode 100644 index 994e4d4607..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_skein.c +++ /dev/null @@ -1,701 +0,0 @@ -/*********************************************************************** -** -** Implementation of the Skein hash function. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -************************************************************************/ - -#define SKEIN_PORT_CODE /* instantiate any code in skein_port.h */ - -#include /* get size_t definition */ -#include /* get the memcpy/memset functions */ -#include "c_skein.h" /* get the Skein API definitions */ - -#ifndef SKEIN_512_NIST_MAX_HASHBITS -#define SKEIN_512_NIST_MAX_HASHBITS (512) -#endif - -#define SKEIN_MODIFIER_WORDS ( 2) /* number of modifier (tweak) words */ - -#define SKEIN_512_STATE_WORDS ( 8) -#define SKEIN_MAX_STATE_WORDS (16) - -#define SKEIN_512_STATE_BYTES ( 8*SKEIN_512_STATE_WORDS) -#define SKEIN_512_STATE_BITS (64*SKEIN_512_STATE_WORDS) -#define SKEIN_512_BLOCK_BYTES ( 8*SKEIN_512_STATE_WORDS) - -#define SKEIN_RND_SPECIAL (1000u) -#define SKEIN_RND_KEY_INITIAL (SKEIN_RND_SPECIAL+0u) -#define SKEIN_RND_KEY_INJECT (SKEIN_RND_SPECIAL+1u) -#define SKEIN_RND_FEED_FWD (SKEIN_RND_SPECIAL+2u) - -typedef struct -{ - size_t hashBitLen; /* size of hash result, in bits */ - size_t bCnt; /* current byte count in buffer b[] */ - u64b_t T[SKEIN_MODIFIER_WORDS]; /* tweak words: T[0]=byte cnt, T[1]=flags */ -} Skein_Ctxt_Hdr_t; - -typedef struct /* 512-bit Skein hash context structure */ -{ - Skein_Ctxt_Hdr_t h; /* common header context variables */ - u64b_t X[SKEIN_512_STATE_WORDS]; /* chaining variables */ - u08b_t b[SKEIN_512_BLOCK_BYTES]; /* partial block buffer (8-byte aligned) */ -} Skein_512_Ctxt_t; - -/* Skein APIs for (incremental) "straight hashing" */ -static int Skein_512_Init (Skein_512_Ctxt_t *ctx, size_t hashBitLen); -static int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt); -static int Skein_512_Final (Skein_512_Ctxt_t *ctx, u08b_t * hashVal); - -#ifndef SKEIN_TREE_HASH -#define SKEIN_TREE_HASH (1) -#endif - -/***************************************************************** -** "Internal" Skein definitions -** -- not needed for sequential hashing API, but will be -** helpful for other uses of Skein (e.g., tree hash mode). -** -- included here so that they can be shared between -** reference and optimized code. -******************************************************************/ - -/* tweak word T[1]: bit field starting positions */ -#define SKEIN_T1_BIT(BIT) ((BIT) - 64) /* offset 64 because it's the second word */ - -#define SKEIN_T1_POS_TREE_LVL SKEIN_T1_BIT(112) /* bits 112..118: level in hash tree */ -#define SKEIN_T1_POS_BIT_PAD SKEIN_T1_BIT(119) /* bit 119 : partial final input byte */ -#define SKEIN_T1_POS_BLK_TYPE SKEIN_T1_BIT(120) /* bits 120..125: type field */ -#define SKEIN_T1_POS_FIRST SKEIN_T1_BIT(126) /* bits 126 : first block flag */ -#define SKEIN_T1_POS_FINAL SKEIN_T1_BIT(127) /* bit 127 : final block flag */ - -/* tweak word T[1]: flag bit definition(s) */ -#define SKEIN_T1_FLAG_FIRST (((u64b_t) 1 ) << SKEIN_T1_POS_FIRST) -#define SKEIN_T1_FLAG_FINAL (((u64b_t) 1 ) << SKEIN_T1_POS_FINAL) -#define SKEIN_T1_FLAG_BIT_PAD (((u64b_t) 1 ) << SKEIN_T1_POS_BIT_PAD) - -/* tweak word T[1]: tree level bit field mask */ -#define SKEIN_T1_TREE_LVL_MASK (((u64b_t)0x7F) << SKEIN_T1_POS_TREE_LVL) -#define SKEIN_T1_TREE_LEVEL(n) (((u64b_t) (n)) << SKEIN_T1_POS_TREE_LVL) - -/* tweak word T[1]: block type field */ -#define SKEIN_BLK_TYPE_KEY ( 0) /* key, for MAC and KDF */ -#define SKEIN_BLK_TYPE_CFG ( 4) /* configuration block */ -#define SKEIN_BLK_TYPE_PERS ( 8) /* personalization string */ -#define SKEIN_BLK_TYPE_PK (12) /* public key (for digital signature hashing) */ -#define SKEIN_BLK_TYPE_KDF (16) /* key identifier for KDF */ -#define SKEIN_BLK_TYPE_NONCE (20) /* nonce for PRNG */ -#define SKEIN_BLK_TYPE_MSG (48) /* message processing */ -#define SKEIN_BLK_TYPE_OUT (63) /* output stage */ -#define SKEIN_BLK_TYPE_MASK (63) /* bit field mask */ - -#define SKEIN_T1_BLK_TYPE(T) (((u64b_t) (SKEIN_BLK_TYPE_##T)) << SKEIN_T1_POS_BLK_TYPE) -#define SKEIN_T1_BLK_TYPE_KEY SKEIN_T1_BLK_TYPE(KEY) /* key, for MAC and KDF */ -#define SKEIN_T1_BLK_TYPE_CFG SKEIN_T1_BLK_TYPE(CFG) /* configuration block */ -#define SKEIN_T1_BLK_TYPE_PERS SKEIN_T1_BLK_TYPE(PERS) /* personalization string */ -#define SKEIN_T1_BLK_TYPE_PK SKEIN_T1_BLK_TYPE(PK) /* public key (for digital signature hashing) */ -#define SKEIN_T1_BLK_TYPE_KDF SKEIN_T1_BLK_TYPE(KDF) /* key identifier for KDF */ -#define SKEIN_T1_BLK_TYPE_NONCE SKEIN_T1_BLK_TYPE(NONCE)/* nonce for PRNG */ -#define SKEIN_T1_BLK_TYPE_MSG SKEIN_T1_BLK_TYPE(MSG) /* message processing */ -#define SKEIN_T1_BLK_TYPE_OUT SKEIN_T1_BLK_TYPE(OUT) /* output stage */ -#define SKEIN_T1_BLK_TYPE_MASK SKEIN_T1_BLK_TYPE(MASK) /* field bit mask */ - -#define SKEIN_T1_BLK_TYPE_CFG_FINAL (SKEIN_T1_BLK_TYPE_CFG | SKEIN_T1_FLAG_FINAL) -#define SKEIN_T1_BLK_TYPE_OUT_FINAL (SKEIN_T1_BLK_TYPE_OUT | SKEIN_T1_FLAG_FINAL) - -#define SKEIN_VERSION (1) - -#ifndef SKEIN_ID_STRING_LE /* allow compile-time personalization */ -#define SKEIN_ID_STRING_LE (0x33414853) /* "SHA3" (little-endian)*/ -#endif - -#define SKEIN_MK_64(hi32,lo32) ((lo32) + (((u64b_t) (hi32)) << 32)) -#define SKEIN_SCHEMA_VER SKEIN_MK_64(SKEIN_VERSION,SKEIN_ID_STRING_LE) -#define SKEIN_KS_PARITY SKEIN_MK_64(0x1BD11BDA,0xA9FC1A22) - -#define SKEIN_CFG_STR_LEN (4*8) - -/* bit field definitions in config block treeInfo word */ -#define SKEIN_CFG_TREE_LEAF_SIZE_POS ( 0) -#define SKEIN_CFG_TREE_NODE_SIZE_POS ( 8) -#define SKEIN_CFG_TREE_MAX_LEVEL_POS (16) - -#define SKEIN_CFG_TREE_LEAF_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_LEAF_SIZE_POS) -#define SKEIN_CFG_TREE_NODE_SIZE_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_NODE_SIZE_POS) -#define SKEIN_CFG_TREE_MAX_LEVEL_MSK (((u64b_t) 0xFF) << SKEIN_CFG_TREE_MAX_LEVEL_POS) - -#define SKEIN_CFG_TREE_INFO(leaf,node,maxLvl) \ - ( (((u64b_t)(leaf )) << SKEIN_CFG_TREE_LEAF_SIZE_POS) | \ - (((u64b_t)(node )) << SKEIN_CFG_TREE_NODE_SIZE_POS) | \ - (((u64b_t)(maxLvl)) << SKEIN_CFG_TREE_MAX_LEVEL_POS) ) - -#define SKEIN_CFG_TREE_INFO_SEQUENTIAL SKEIN_CFG_TREE_INFO(0,0,0) /* use as treeInfo in InitExt() call for sequential processing */ - -/* -** Skein macros for getting/setting tweak words, etc. -** These are useful for partial input bytes, hash tree init/update, etc. -**/ -#define Skein_Get_Tweak(ctxPtr,TWK_NUM) ((ctxPtr)->h.T[TWK_NUM]) -#define Skein_Set_Tweak(ctxPtr,TWK_NUM,tVal) {(ctxPtr)->h.T[TWK_NUM] = (tVal);} - -#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr,0) -#define Skein_Get_T1(ctxPtr) Skein_Get_Tweak(ctxPtr,1) -#define Skein_Set_T0(ctxPtr,T0) Skein_Set_Tweak(ctxPtr,0,T0) -#define Skein_Set_T1(ctxPtr,T1) Skein_Set_Tweak(ctxPtr,1,T1) - -/* set both tweak words at once */ -#define Skein_Set_T0_T1(ctxPtr,T0,T1) \ -{ \ - Skein_Set_T0(ctxPtr,(T0)); \ - Skein_Set_T1(ctxPtr,(T1)); \ -} - -#define Skein_Set_Type(ctxPtr,BLK_TYPE) \ - Skein_Set_T1(ctxPtr,SKEIN_T1_BLK_TYPE_##BLK_TYPE) - -/* set up for starting with a new type: h.T[0]=0; h.T[1] = NEW_TYPE; h.bCnt=0; */ -#define Skein_Start_New_Type(ctxPtr,BLK_TYPE) \ -{ Skein_Set_T0_T1(ctxPtr,0,SKEIN_T1_FLAG_FIRST | SKEIN_T1_BLK_TYPE_##BLK_TYPE); (ctxPtr)->h.bCnt=0; } - -#define Skein_Clear_First_Flag(hdr) { (hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; } -#define Skein_Set_Bit_Pad_Flag(hdr) { (hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; } - -#define Skein_Set_Tree_Level(hdr,height) { (hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height);} - -/***************************************************************** -** "Internal" Skein definitions for debugging and error checking -******************************************************************/ -#define Skein_Show_Block(bits,ctx,X,blkPtr,wPtr,ksEvenPtr,ksOddPtr) -#define Skein_Show_Round(bits,ctx,r,X) -#define Skein_Show_R_Ptr(bits,ctx,r,X_ptr) -#define Skein_Show_Final(bits,ctx,cnt,outPtr) -#define Skein_Show_Key(bits,ctx,key,keyBytes) - - -#ifndef SKEIN_ERR_CHECK /* run-time checks (e.g., bad params, uninitialized context)? */ -#define Skein_Assert(x,retCode)/* default: ignore all Asserts, for performance */ -#define Skein_assert(x) -#elif defined(SKEIN_ASSERT) -#include -#define Skein_Assert(x,retCode) assert(x) -#define Skein_assert(x) assert(x) -#else -#include -#define Skein_Assert(x,retCode) { if (!(x)) return retCode; } /* caller error */ -#define Skein_assert(x) assert(x) /* internal error */ -#endif - -/***************************************************************** -** Skein block function constants (shared across Ref and Opt code) -******************************************************************/ -enum -{ - /* Skein_512 round rotation constants */ - R_512_0_0=46, R_512_0_1=36, R_512_0_2=19, R_512_0_3=37, - R_512_1_0=33, R_512_1_1=27, R_512_1_2=14, R_512_1_3=42, - R_512_2_0=17, R_512_2_1=49, R_512_2_2=36, R_512_2_3=39, - R_512_3_0=44, R_512_3_1= 9, R_512_3_2=54, R_512_3_3=56, - R_512_4_0=39, R_512_4_1=30, R_512_4_2=34, R_512_4_3=24, - R_512_5_0=13, R_512_5_1=50, R_512_5_2=10, R_512_5_3=17, - R_512_6_0=25, R_512_6_1=29, R_512_6_2=39, R_512_6_3=43, - R_512_7_0= 8, R_512_7_1=35, R_512_7_2=56, R_512_7_3=22, -}; - -#ifndef SKEIN_ROUNDS -#define SKEIN_512_ROUNDS_TOTAL (72) -#else /* allow command-line define in range 8*(5..14) */ -#define SKEIN_512_ROUNDS_TOTAL (8*((((SKEIN_ROUNDS/ 10) + 5) % 10) + 5)) -#endif - - -/* -***************** Pre-computed Skein IVs ******************* -** -** NOTE: these values are not "magic" constants, but -** are generated using the Threefish block function. -** They are pre-computed here only for speed; i.e., to -** avoid the need for a Threefish call during Init(). -** -** The IV for any fixed hash length may be pre-computed. -** Only the most common values are included here. -** -************************************************************ -**/ - -#define MK_64 SKEIN_MK_64 - -/* blkSize = 512 bits. hashSize = 256 bits */ -const u64b_t SKEIN_512_IV_256[] = - { - MK_64(0xCCD044A1,0x2FDB3E13), - MK_64(0xE8359030,0x1A79A9EB), - MK_64(0x55AEA061,0x4F816E6F), - MK_64(0x2A2767A4,0xAE9B94DB), - MK_64(0xEC06025E,0x74DD7683), - MK_64(0xE7A436CD,0xC4746251), - MK_64(0xC36FBAF9,0x393AD185), - MK_64(0x3EEDBA18,0x33EDFC13) - }; - -#ifndef SKEIN_USE_ASM -#define SKEIN_USE_ASM (0) /* default is all C code (no ASM) */ -#endif - -#ifndef SKEIN_LOOP -#define SKEIN_LOOP 001 /* default: unroll 256 and 512, but not 1024 */ -#endif - -#define BLK_BITS (WCNT*64) /* some useful definitions for code here */ -#define KW_TWK_BASE (0) -#define KW_KEY_BASE (3) -#define ks (kw + KW_KEY_BASE) -#define ts (kw + KW_TWK_BASE) - -#ifdef SKEIN_DEBUG -#define DebugSaveTweak(ctx) { ctx->h.T[0] = ts[0]; ctx->h.T[1] = ts[1]; } -#else -#define DebugSaveTweak(ctx) -#endif - -/***************************** Skein_512 ******************************/ -#if !(SKEIN_USE_ASM & 512) -static void Skein_512_Process_Block(Skein_512_Ctxt_t *ctx,const u08b_t *blkPtr,size_t blkCnt,size_t byteCntAdd) - { /* do it in C */ - enum - { - WCNT = SKEIN_512_STATE_WORDS - }; -#undef RCNT -#define RCNT (SKEIN_512_ROUNDS_TOTAL/8) - -#ifdef SKEIN_LOOP /* configure how much to unroll the loop */ -#define SKEIN_UNROLL_512 (((SKEIN_LOOP)/10)%10) -#else -#define SKEIN_UNROLL_512 (0) -#endif - -#if SKEIN_UNROLL_512 -#if (RCNT % SKEIN_UNROLL_512) -#error "Invalid SKEIN_UNROLL_512" /* sanity check on unroll count */ -#endif - size_t r; - u64b_t kw[WCNT+4+RCNT*2]; /* key schedule words : chaining vars + tweak + "rotation"*/ -#else - u64b_t kw[WCNT+4]; /* key schedule words : chaining vars + tweak */ -#endif - u64b_t X0,X1,X2,X3,X4,X5,X6,X7; /* local copy of vars, for speed */ - u64b_t w [WCNT]; /* local copy of input block */ -#ifdef SKEIN_DEBUG - const u64b_t *Xptr[8]; /* use for debugging (help compiler put Xn in registers) */ - Xptr[0] = &X0; Xptr[1] = &X1; Xptr[2] = &X2; Xptr[3] = &X3; - Xptr[4] = &X4; Xptr[5] = &X5; Xptr[6] = &X6; Xptr[7] = &X7; -#endif - - Skein_assert(blkCnt != 0); /* never call with blkCnt == 0! */ - ts[0] = ctx->h.T[0]; - ts[1] = ctx->h.T[1]; - do { - /* this implementation only supports 2**64 input bytes (no carry out here) */ - ts[0] += byteCntAdd; /* update processed length */ - - /* precompute the key schedule for this block */ - ks[0] = ctx->X[0]; - ks[1] = ctx->X[1]; - ks[2] = ctx->X[2]; - ks[3] = ctx->X[3]; - ks[4] = ctx->X[4]; - ks[5] = ctx->X[5]; - ks[6] = ctx->X[6]; - ks[7] = ctx->X[7]; - ks[8] = ks[0] ^ ks[1] ^ ks[2] ^ ks[3] ^ - ks[4] ^ ks[5] ^ ks[6] ^ ks[7] ^ SKEIN_KS_PARITY; - - ts[2] = ts[0] ^ ts[1]; - - Skein_Get64_LSB_First(w,blkPtr,WCNT); /* get input block in little-endian format */ - DebugSaveTweak(ctx); - Skein_Show_Block(BLK_BITS,&ctx->h,ctx->X,blkPtr,w,ks,ts); - - X0 = w[0] + ks[0]; /* do the first full key injection */ - X1 = w[1] + ks[1]; - X2 = w[2] + ks[2]; - X3 = w[3] + ks[3]; - X4 = w[4] + ks[4]; - X5 = w[5] + ks[5] + ts[0]; - X6 = w[6] + ks[6] + ts[1]; - X7 = w[7] + ks[7]; - - blkPtr += SKEIN_512_BLOCK_BYTES; - - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INITIAL,Xptr); - /* run the rounds */ -#define Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - X##p0 += X##p1; X##p1 = RotL_64(X##p1,ROT##_0); X##p1 ^= X##p0; \ - X##p2 += X##p3; X##p3 = RotL_64(X##p3,ROT##_1); X##p3 ^= X##p2; \ - X##p4 += X##p5; X##p5 = RotL_64(X##p5,ROT##_2); X##p5 ^= X##p4; \ - X##p6 += X##p7; X##p7 = RotL_64(X##p7,ROT##_3); X##p7 ^= X##p6; \ - -#if SKEIN_UNROLL_512 == 0 -#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) /* unrolled */ \ - Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,rNum,Xptr); - -#define I512(R) \ - X0 += ks[((R)+1) % 9]; /* inject the key schedule value */ \ - X1 += ks[((R)+2) % 9]; \ - X2 += ks[((R)+3) % 9]; \ - X3 += ks[((R)+4) % 9]; \ - X4 += ks[((R)+5) % 9]; \ - X5 += ks[((R)+6) % 9] + ts[((R)+1) % 3]; \ - X6 += ks[((R)+7) % 9] + ts[((R)+2) % 3]; \ - X7 += ks[((R)+8) % 9] + (R)+1; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); -#else /* looping version */ -#define R512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Round512(p0,p1,p2,p3,p4,p5,p6,p7,ROT,rNum) \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,4*(r-1)+rNum,Xptr); - -#define I512(R) \ - X0 += ks[r+(R)+0]; /* inject the key schedule value */ \ - X1 += ks[r+(R)+1]; \ - X2 += ks[r+(R)+2]; \ - X3 += ks[r+(R)+3]; \ - X4 += ks[r+(R)+4]; \ - X5 += ks[r+(R)+5] + ts[r+(R)+0]; \ - X6 += ks[r+(R)+6] + ts[r+(R)+1]; \ - X7 += ks[r+(R)+7] + r+(R) ; \ - ks[r + (R)+8] = ks[r+(R)-1]; /* rotate key schedule */ \ - ts[r + (R)+2] = ts[r+(R)-1]; \ - Skein_Show_R_Ptr(BLK_BITS,&ctx->h,SKEIN_RND_KEY_INJECT,Xptr); - - for (r=1;r < 2*RCNT;r+=2*SKEIN_UNROLL_512) /* loop thru it */ -#endif /* end of looped code definitions */ - { -#define R512_8_rounds(R) /* do 8 full rounds */ \ - R512(0,1,2,3,4,5,6,7,R_512_0,8*(R)+ 1); \ - R512(2,1,4,7,6,5,0,3,R_512_1,8*(R)+ 2); \ - R512(4,1,6,3,0,5,2,7,R_512_2,8*(R)+ 3); \ - R512(6,1,0,7,2,5,4,3,R_512_3,8*(R)+ 4); \ - I512(2*(R)); \ - R512(0,1,2,3,4,5,6,7,R_512_4,8*(R)+ 5); \ - R512(2,1,4,7,6,5,0,3,R_512_5,8*(R)+ 6); \ - R512(4,1,6,3,0,5,2,7,R_512_6,8*(R)+ 7); \ - R512(6,1,0,7,2,5,4,3,R_512_7,8*(R)+ 8); \ - I512(2*(R)+1); /* and key injection */ - - R512_8_rounds( 0); - -#define R512_Unroll_R(NN) ((SKEIN_UNROLL_512 == 0 && SKEIN_512_ROUNDS_TOTAL/8 > (NN)) || (SKEIN_UNROLL_512 > (NN))) - - #if R512_Unroll_R( 1) - R512_8_rounds( 1); - #endif - #if R512_Unroll_R( 2) - R512_8_rounds( 2); - #endif - #if R512_Unroll_R( 3) - R512_8_rounds( 3); - #endif - #if R512_Unroll_R( 4) - R512_8_rounds( 4); - #endif - #if R512_Unroll_R( 5) - R512_8_rounds( 5); - #endif - #if R512_Unroll_R( 6) - R512_8_rounds( 6); - #endif - #if R512_Unroll_R( 7) - R512_8_rounds( 7); - #endif - #if R512_Unroll_R( 8) - R512_8_rounds( 8); - #endif - #if R512_Unroll_R( 9) - R512_8_rounds( 9); - #endif - #if R512_Unroll_R(10) - R512_8_rounds(10); - #endif - #if R512_Unroll_R(11) - R512_8_rounds(11); - #endif - #if R512_Unroll_R(12) - R512_8_rounds(12); - #endif - #if R512_Unroll_R(13) - R512_8_rounds(13); - #endif - #if R512_Unroll_R(14) - R512_8_rounds(14); - #endif - #if (SKEIN_UNROLL_512 > 14) -#error "need more unrolling in Skein_512_Process_Block" - #endif - } - - /* do the final "feedforward" xor, update context chaining vars */ - ctx->X[0] = X0 ^ w[0]; - ctx->X[1] = X1 ^ w[1]; - ctx->X[2] = X2 ^ w[2]; - ctx->X[3] = X3 ^ w[3]; - ctx->X[4] = X4 ^ w[4]; - ctx->X[5] = X5 ^ w[5]; - ctx->X[6] = X6 ^ w[6]; - ctx->X[7] = X7 ^ w[7]; - Skein_Show_Round(BLK_BITS,&ctx->h,SKEIN_RND_FEED_FWD,ctx->X); - - ts[1] &= ~SKEIN_T1_FLAG_FIRST; - } - while (--blkCnt); - ctx->h.T[0] = ts[0]; - ctx->h.T[1] = ts[1]; - } -#endif - -/*****************************************************************/ -/* 512-bit Skein */ -/*****************************************************************/ - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* init the context for a straight hashing operation */ -static int Skein_512_Init(Skein_512_Ctxt_t *ctx, size_t hashBitLen) - { - union - { - u08b_t b[SKEIN_512_STATE_BYTES]; - u64b_t w[SKEIN_512_STATE_WORDS]; - } cfg; /* config block */ - - Skein_Assert(hashBitLen > 0,SKEIN_BAD_HASHLEN); - ctx->h.hashBitLen = hashBitLen; /* output hash bit count */ - - switch (hashBitLen) - { /* use pre-computed values, where available */ -#ifndef SKEIN_NO_PRECOMP - case 256: memcpy(ctx->X,SKEIN_512_IV_256,sizeof(ctx->X)); break; -#endif - default: - /* here if there is no precomputed IV value available */ - /* build/process the config block, type == CONFIG (could be precomputed) */ - Skein_Start_New_Type(ctx,CFG_FINAL); /* set tweaks: T0=0; T1=CFG | FINAL */ - - cfg.w[0] = Skein_Swap64(SKEIN_SCHEMA_VER); /* set the schema, version */ - cfg.w[1] = Skein_Swap64(hashBitLen); /* hash result length in bits */ - cfg.w[2] = Skein_Swap64(SKEIN_CFG_TREE_INFO_SEQUENTIAL); - memset(&cfg.w[3],0,sizeof(cfg) - 3*sizeof(cfg.w[0])); /* zero pad config block */ - - /* compute the initial chaining values from config block */ - memset(ctx->X,0,sizeof(ctx->X)); /* zero the chaining variables */ - Skein_512_Process_Block(ctx,cfg.b,1,SKEIN_CFG_STR_LEN); - break; - } - - /* The chaining vars ctx->X are now initialized for the given hashBitLen. */ - /* Set up to process the data message portion of the hash (default) */ - Skein_Start_New_Type(ctx,MSG); /* T0=0, T1= MSG type */ - - return SKEIN_SUCCESS; - } - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process the input bytes */ -static int Skein_512_Update(Skein_512_Ctxt_t *ctx, const u08b_t *msg, size_t msgByteCnt) - { - size_t n; - - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ - - /* process full blocks, if any */ - if (msgByteCnt + ctx->h.bCnt > SKEIN_512_BLOCK_BYTES) - { - if (ctx->h.bCnt) /* finish up any buffered message data */ - { - n = SKEIN_512_BLOCK_BYTES - ctx->h.bCnt; /* # bytes free in buffer b[] */ - if (n) - { - Skein_assert(n < msgByteCnt); /* check on our logic here */ - memcpy(&ctx->b[ctx->h.bCnt],msg,n); - msgByteCnt -= n; - msg += n; - ctx->h.bCnt += n; - } - Skein_assert(ctx->h.bCnt == SKEIN_512_BLOCK_BYTES); - Skein_512_Process_Block(ctx,ctx->b,1,SKEIN_512_BLOCK_BYTES); - ctx->h.bCnt = 0; - } - /* now process any remaining full blocks, directly from input message data */ - if (msgByteCnt > SKEIN_512_BLOCK_BYTES) - { - n = (msgByteCnt-1) / SKEIN_512_BLOCK_BYTES; /* number of full blocks to process */ - Skein_512_Process_Block(ctx,msg,n,SKEIN_512_BLOCK_BYTES); - msgByteCnt -= n * SKEIN_512_BLOCK_BYTES; - msg += n * SKEIN_512_BLOCK_BYTES; - } - Skein_assert(ctx->h.bCnt == 0); - } - - /* copy any remaining source message data bytes into b[] */ - if (msgByteCnt) - { - Skein_assert(msgByteCnt + ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES); - memcpy(&ctx->b[ctx->h.bCnt],msg,msgByteCnt); - ctx->h.bCnt += msgByteCnt; - } - - return SKEIN_SUCCESS; - } - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize the hash computation and output the result */ -static int Skein_512_Final(Skein_512_Ctxt_t *ctx, u08b_t *hashVal) - { - size_t i,n,byteCnt; - u64b_t X[SKEIN_512_STATE_WORDS]; - Skein_Assert(ctx->h.bCnt <= SKEIN_512_BLOCK_BYTES,SKEIN_FAIL); /* catch uninitialized context */ - - ctx->h.T[1] |= SKEIN_T1_FLAG_FINAL; /* tag as the final block */ - if (ctx->h.bCnt < SKEIN_512_BLOCK_BYTES) /* zero pad b[] if necessary */ - memset(&ctx->b[ctx->h.bCnt],0,SKEIN_512_BLOCK_BYTES - ctx->h.bCnt); - - Skein_512_Process_Block(ctx,ctx->b,1,ctx->h.bCnt); /* process the final block */ - - /* now output the result */ - byteCnt = (ctx->h.hashBitLen + 7) >> 3; /* total number of output bytes */ - - /* run Threefish in "counter mode" to generate output */ - memset(ctx->b,0,sizeof(ctx->b)); /* zero out b[], so it can hold the counter */ - memcpy(X,ctx->X,sizeof(X)); /* keep a local copy of counter mode "key" */ - for (i=0;i*SKEIN_512_BLOCK_BYTES < byteCnt;i++) - { - ((u64b_t *)ctx->b)[0]= Skein_Swap64((u64b_t) i); /* build the counter block */ - Skein_Start_New_Type(ctx,OUT_FINAL); - Skein_512_Process_Block(ctx,ctx->b,1,sizeof(u64b_t)); /* run "counter mode" */ - n = byteCnt - i*SKEIN_512_BLOCK_BYTES; /* number of output bytes left to go */ - if (n >= SKEIN_512_BLOCK_BYTES) - n = SKEIN_512_BLOCK_BYTES; - Skein_Put64_LSB_First(hashVal+i*SKEIN_512_BLOCK_BYTES,ctx->X,n); /* "output" the ctr mode bytes */ - Skein_Show_Final(512,&ctx->h,n,hashVal+i*SKEIN_512_BLOCK_BYTES); - memcpy(ctx->X,X,sizeof(X)); /* restore the counter mode key for next time */ - } - return SKEIN_SUCCESS; - } - -#if defined(SKEIN_CODE_SIZE) || defined(SKEIN_PERF) -static size_t Skein_512_API_CodeSize(void) - { - return ((u08b_t *) Skein_512_API_CodeSize) - - ((u08b_t *) Skein_512_Init); - } -#endif - -typedef struct -{ - uint_t statebits; /* 256, 512, or 1024 */ - union - { - Skein_Ctxt_Hdr_t h; /* common header "overlay" */ - Skein_512_Ctxt_t ctx_512; - } u; -} -hashState; - -/* "incremental" hashing API */ -static SkeinHashReturn Init (hashState *state, int hashbitlen); -static SkeinHashReturn Update(hashState *state, const SkeinBitSequence *data, SkeinDataLength databitlen); -static SkeinHashReturn Final (hashState *state, SkeinBitSequence *hashval); - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* select the context size and init the context */ -static SkeinHashReturn Init(hashState *state, int hashbitlen) -{ - state->statebits = 64*SKEIN_512_STATE_WORDS; - return Skein_512_Init(&state->u.ctx_512,(size_t) hashbitlen); -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* process data to be hashed */ -static SkeinHashReturn Update(hashState *state, const SkeinBitSequence *data, SkeinDataLength databitlen) -{ - /* only the final Update() call is allowed do partial bytes, else assert an error */ - Skein_Assert((state->u.h.T[1] & SKEIN_T1_FLAG_BIT_PAD) == 0 || databitlen == 0, SKEIN_FAIL); - - Skein_Assert(state->statebits % 256 == 0 && (state->statebits-256) < 1024,SKEIN_FAIL); - if ((databitlen & 7) == 0) /* partial bytes? */ - { - return Skein_512_Update(&state->u.ctx_512,data,databitlen >> 3); - } - else - { /* handle partial final byte */ - size_t bCnt = (databitlen >> 3) + 1; /* number of bytes to handle (nonzero here!) */ - u08b_t b,mask; - - mask = (u08b_t) (1u << (7 - (databitlen & 7))); /* partial byte bit mask */ - b = (u08b_t) ((data[bCnt-1] & (0-mask)) | mask); /* apply bit padding on final byte */ - - Skein_512_Update(&state->u.ctx_512,data,bCnt-1); /* process all but the final byte */ - Skein_512_Update(&state->u.ctx_512,&b , 1 ); /* process the (masked) partial byte */ - Skein_Set_Bit_Pad_Flag(state->u.h); /* set tweak flag for the final call */ - - return SKEIN_SUCCESS; - } -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* finalize hash computation and output the result (hashbitlen bits) */ -static SkeinHashReturn Final(hashState *state, SkeinBitSequence *hashval) -{ - Skein_Assert(state->statebits % 256 == 0 && (state->statebits-256) < 1024,FAIL); - return Skein_512_Final(&state->u.ctx_512,hashval); -} - -/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ -/* all-in-one hash function */ -SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence *data, /* all-in-one call */ - SkeinDataLength databitlen,SkeinBitSequence *hashval) -{ - hashState state; - SkeinHashReturn r = Init(&state,hashbitlen); - if (r == SKEIN_SUCCESS) - { /* these calls do not fail when called properly */ - r = Update(&state,data,databitlen); - Final(&state,hashval); - } - return r; -} - -void xmr_skein(const SkeinBitSequence *data, SkeinBitSequence *hashval){ - #define XMR_HASHBITLEN 256 - #define XMR_DATABITLEN 1600 - - // Init - hashState state; - state.statebits = 64*SKEIN_512_STATE_WORDS; - - // Skein_512_Init(&state.u.ctx_512, (size_t)XMR_HASHBITLEN); - state.u.ctx_512.h.hashBitLen = XMR_HASHBITLEN; - memcpy(state.u.ctx_512.X,SKEIN_512_IV_256,sizeof(state.u.ctx_512.X)); - Skein_512_Ctxt_t* ctx = &(state.u.ctx_512); - Skein_Start_New_Type(ctx,MSG); - - // Update - if ((XMR_DATABITLEN & 7) == 0){ /* partial bytes? */ - Skein_512_Update(&state.u.ctx_512,data,XMR_DATABITLEN >> 3); - }else{ /* handle partial final byte */ - size_t bCnt = (XMR_DATABITLEN >> 3) + 1; /* number of bytes to handle (nonzero here!) */ - u08b_t b,mask; - - mask = (u08b_t) (1u << (7 - (XMR_DATABITLEN & 7))); /* partial byte bit mask */ - b = (u08b_t) ((data[bCnt-1] & (0-mask)) | mask); /* apply bit padding on final byte */ - - Skein_512_Update(&state.u.ctx_512,data,bCnt-1); /* process all but the final byte */ - Skein_512_Update(&state.u.ctx_512,&b , 1 ); /* process the (masked) partial byte */ - Skein_Set_Bit_Pad_Flag(state.u.h); /* set tweak flag for the final call */ - } - - // Finalize - Skein_512_Final(&state.u.ctx_512, hashval); -} diff --git a/src/Native/libcryptonight/xmrig/crypto/c_skein.h b/src/Native/libcryptonight/xmrig/crypto/c_skein.h deleted file mode 100644 index c642e265c0..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/c_skein.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _SKEIN_H_ -#define _SKEIN_H_ 1 -/************************************************************************** -** -** Interface declarations and internal definitions for Skein hashing. -** -** Source code author: Doug Whiting, 2008. -** -** This algorithm and source code is released to the public domain. -** -*************************************************************************** -** -** The following compile-time switches may be defined to control some -** tradeoffs between speed, code size, error checking, and security. -** -** The "default" note explains what happens when the switch is not defined. -** -** SKEIN_DEBUG -- make callouts from inside Skein code -** to examine/display intermediate values. -** [default: no callouts (no overhead)] -** -** SKEIN_ERR_CHECK -- how error checking is handled inside Skein -** code. If not defined, most error checking -** is disabled (for performance). Otherwise, -** the switch value is interpreted as: -** 0: use assert() to flag errors -** 1: return SKEIN_FAIL to flag errors -** -***************************************************************************/ -#include "skein_port.h" /* get platform-specific definitions */ - -typedef enum -{ - SKEIN_SUCCESS = 0, /* return codes from Skein calls */ - SKEIN_FAIL = 1, - SKEIN_BAD_HASHLEN = 2 -} -SkeinHashReturn; - -typedef size_t SkeinDataLength; /* bit count type */ -typedef u08b_t SkeinBitSequence; /* bit stream type */ - -/* "all-in-one" call */ -SkeinHashReturn skein_hash(int hashbitlen, const SkeinBitSequence *data, - SkeinDataLength databitlen, SkeinBitSequence *hashval); - -void xmr_skein(const SkeinBitSequence *data, SkeinBitSequence *hashval); - -#endif /* ifndef _SKEIN_H_ */ diff --git a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_arm.cpp b/src/Native/libcryptonight/xmrig/crypto/cn_gpu_arm.cpp deleted file mode 100644 index 2ac9ff1e38..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_arm.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#include - - -#include "crypto/CryptoNight_constants.h" - - -#if !defined(__ARM_64BIT_STATE) -float32x4_t vdivq_f32(const float32x4_t a, const float32x4_t b) { - const float32x4_t inv = vrecpeq_f32(b); - return vmulq_f32(a, vmulq_f32(vrecpsq_f32(b, inv), inv)); -} -#endif - - -inline void vandq_f32(float32x4_t &v, uint32_t v2) -{ - uint32x4_t vc = vdupq_n_u32(v2); - v = (float32x4_t)vandq_u32((uint32x4_t)v, vc); -} - - -inline void vorq_f32(float32x4_t &v, uint32_t v2) -{ - uint32x4_t vc = vdupq_n_u32(v2); - v = (float32x4_t)vorrq_u32((uint32x4_t)v, vc); -} - - -template -inline void vrot_si32(int32x4_t &r) -{ - r = (int32x4_t)vextq_s8((int8x16_t)r, (int8x16_t)r, v); -} - -template <> -inline void vrot_si32<0>(int32x4_t &r) -{ -} - - -inline uint32_t vheor_s32(const int32x4_t &v) -{ - int32x4_t v0 = veorq_s32(v, vrev64q_s32(v)); - int32x2_t vf = veor_s32(vget_high_s32(v0), vget_low_s32(v0)); - return (uint32_t)vget_lane_s32(vf, 0); -} - - -inline void prep_dv(int32_t *idx, int32x4_t &v, float32x4_t &n) -{ - v = vld1q_s32(idx); - n = vcvtq_f32_s32(v); -} - - -inline void sub_round(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, const float32x4_t &rnd_c, float32x4_t &n, float32x4_t &d, float32x4_t &c) -{ - float32x4_t ln1 = vaddq_f32(n1, c); - float32x4_t nn = vmulq_f32(n0, c); - nn = vmulq_f32(ln1, vmulq_f32(nn, nn)); - vandq_f32(nn, 0xFEFFFFFF); - vorq_f32(nn, 0x00800000); - n = vaddq_f32(n, nn); - - float32x4_t ln3 = vsubq_f32(n3, c); - float32x4_t dd = vmulq_f32(n2, c); - dd = vmulq_f32(ln3, vmulq_f32(dd, dd)); - vandq_f32(dd, 0xFEFFFFFF); - vorq_f32(dd, 0x00800000); - d = vaddq_f32(d, dd); - - //Constant feedback - c = vaddq_f32(c, rnd_c); - c = vaddq_f32(c, vdupq_n_f32(0.734375f)); - float32x4_t r = vaddq_f32(nn, dd); - vandq_f32(r, 0x807FFFFF); - vorq_f32(r, 0x40000000); - c = vaddq_f32(c, r); -} - - -inline void round_compute(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, const float32x4_t &rnd_c, float32x4_t &c, float32x4_t &r) -{ - float32x4_t n = vdupq_n_f32(0.0f), d = vdupq_n_f32(0.0f); - - sub_round(n0, n1, n2, n3, rnd_c, n, d, c); - sub_round(n1, n2, n3, n0, rnd_c, n, d, c); - sub_round(n2, n3, n0, n1, rnd_c, n, d, c); - sub_round(n3, n0, n1, n2, rnd_c, n, d, c); - sub_round(n3, n2, n1, n0, rnd_c, n, d, c); - sub_round(n2, n1, n0, n3, rnd_c, n, d, c); - sub_round(n1, n0, n3, n2, rnd_c, n, d, c); - sub_round(n0, n3, n2, n1, rnd_c, n, d, c); - - // Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0 - vandq_f32(d, 0xFF7FFFFF); - vorq_f32(d, 0x40000000); - r = vaddq_f32(r, vdivq_f32(n, d)); -} - - -// 112×4 = 448 -template -inline int32x4_t single_compute(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, float cnt, const float32x4_t &rnd_c, float32x4_t &sum) -{ - float32x4_t c = vdupq_n_f32(cnt); - float32x4_t r = vdupq_n_f32(0.0f); - - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - - // do a quick fmod by setting exp to 2 - vandq_f32(r, 0x807FFFFF); - vorq_f32(r, 0x40000000); - - if (add) { - sum = vaddq_f32(sum, r); - } else { - sum = r; - } - - const float32x4_t cc2 = vdupq_n_f32(536870880.0f); - r = vmulq_f32(r, cc2); // 35 - return vcvtq_s32_f32(r); -} - - -template -inline void single_compute_wrap(const float32x4_t &n0, const float32x4_t &n1, const float32x4_t &n2, const float32x4_t &n3, float cnt, const float32x4_t &rnd_c, float32x4_t &sum, int32x4_t &out) -{ - int32x4_t r = single_compute(n0, n1, n2, n3, cnt, rnd_c, sum); - vrot_si32(r); - out = veorq_s32(out, r); -} - - -template -inline int32_t *scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast(lpad + (idx & MASK) + n * 16); } - - -template -void cn_gpu_inner_arm(const uint8_t *spad, uint8_t *lpad) -{ - uint32_t s = reinterpret_cast(spad)[0] >> 8; - int32_t *idx0 = scratchpad_ptr(lpad, s, 0); - int32_t *idx1 = scratchpad_ptr(lpad, s, 1); - int32_t *idx2 = scratchpad_ptr(lpad, s, 2); - int32_t *idx3 = scratchpad_ptr(lpad, s, 3); - float32x4_t sum0 = vdupq_n_f32(0.0f); - - for (size_t i = 0; i < ITER; i++) { - float32x4_t n0, n1, n2, n3; - int32x4_t v0, v1, v2, v3; - float32x4_t suma, sumb, sum1, sum2, sum3; - - prep_dv(idx0, v0, n0); - prep_dv(idx1, v1, n1); - prep_dv(idx2, v2, n2); - prep_dv(idx3, v3, n3); - float32x4_t rc = sum0; - - int32x4_t out, out2; - out = vdupq_n_s32(0); - single_compute_wrap<0>(n0, n1, n2, n3, 1.3437500f, rc, suma, out); - single_compute_wrap<1>(n0, n2, n3, n1, 1.2812500f, rc, suma, out); - single_compute_wrap<2>(n0, n3, n1, n2, 1.3593750f, rc, sumb, out); - single_compute_wrap<3>(n0, n3, n2, n1, 1.3671875f, rc, sumb, out); - sum0 = vaddq_f32(suma, sumb); - vst1q_s32(idx0, veorq_s32(v0, out)); - out2 = out; - - out = vdupq_n_s32(0); - single_compute_wrap<0>(n1, n0, n2, n3, 1.4296875f, rc, suma, out); - single_compute_wrap<1>(n1, n2, n3, n0, 1.3984375f, rc, suma, out); - single_compute_wrap<2>(n1, n3, n0, n2, 1.3828125f, rc, sumb, out); - single_compute_wrap<3>(n1, n3, n2, n0, 1.3046875f, rc, sumb, out); - sum1 = vaddq_f32(suma, sumb); - vst1q_s32(idx1, veorq_s32(v1, out)); - out2 = veorq_s32(out2, out); - - out = vdupq_n_s32(0); - single_compute_wrap<0>(n2, n1, n0, n3, 1.4140625f, rc, suma, out); - single_compute_wrap<1>(n2, n0, n3, n1, 1.2734375f, rc, suma, out); - single_compute_wrap<2>(n2, n3, n1, n0, 1.2578125f, rc, sumb, out); - single_compute_wrap<3>(n2, n3, n0, n1, 1.2890625f, rc, sumb, out); - sum2 = vaddq_f32(suma, sumb); - vst1q_s32(idx2, veorq_s32(v2, out)); - out2 = veorq_s32(out2, out); - - out = vdupq_n_s32(0); - single_compute_wrap<0>(n3, n1, n2, n0, 1.3203125f, rc, suma, out); - single_compute_wrap<1>(n3, n2, n0, n1, 1.3515625f, rc, suma, out); - single_compute_wrap<2>(n3, n0, n1, n2, 1.3359375f, rc, sumb, out); - single_compute_wrap<3>(n3, n0, n2, n1, 1.4609375f, rc, sumb, out); - sum3 = vaddq_f32(suma, sumb); - vst1q_s32(idx3, veorq_s32(v3, out)); - out2 = veorq_s32(out2, out); - - sum0 = vaddq_f32(sum0, sum1); - sum2 = vaddq_f32(sum2, sum3); - sum0 = vaddq_f32(sum0, sum2); - - const float32x4_t cc1 = vdupq_n_f32(16777216.0f); - const float32x4_t cc2 = vdupq_n_f32(64.0f); - vandq_f32(sum0, 0x7fffffff); // take abs(va) by masking the float sign bit - // vs range 0 - 64 - n0 = vmulq_f32(sum0, cc1); - v0 = vcvtq_s32_f32(n0); - v0 = veorq_s32(v0, out2); - uint32_t n = vheor_s32(v0); - - // vs is now between 0 and 1 - sum0 = vdivq_f32(sum0, cc2); - idx0 = scratchpad_ptr(lpad, n, 0); - idx1 = scratchpad_ptr(lpad, n, 1); - idx2 = scratchpad_ptr(lpad, n, 2); - idx3 = scratchpad_ptr(lpad, n, 3); - } -} - -template void cn_gpu_inner_arm(const uint8_t* spad, uint8_t* lpad); diff --git a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_avx.cpp b/src/Native/libcryptonight/xmrig/crypto/cn_gpu_avx.cpp deleted file mode 100644 index 3dc7cacb72..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_avx.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "crypto/CryptoNight_constants.h" - -#ifdef __GNUC__ -# include -#else -# include -# define __restrict__ __restrict -#endif - -inline void prep_dv_avx(__m256i* idx, __m256i& v, __m256& n01) -{ - v = _mm256_load_si256(idx); - n01 = _mm256_cvtepi32_ps(v); -} - -inline __m256 fma_break(const __m256& x) -{ - // Break the dependency chain by setitng the exp to ?????01 - __m256 xx = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0xFEFFFFFF)), x); - return _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x00800000)), xx); -} - -// 14 -inline void sub_round(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, const __m256& rnd_c, __m256& n, __m256& d, __m256& c) -{ - __m256 nn = _mm256_mul_ps(n0, c); - nn = _mm256_mul_ps(_mm256_add_ps(n1, c), _mm256_mul_ps(nn, nn)); - nn = fma_break(nn); - n = _mm256_add_ps(n, nn); - - __m256 dd = _mm256_mul_ps(n2, c); - dd = _mm256_mul_ps(_mm256_sub_ps(n3, c), _mm256_mul_ps(dd, dd)); - dd = fma_break(dd); - d = _mm256_add_ps(d, dd); - - //Constant feedback - c = _mm256_add_ps(c, rnd_c); - c = _mm256_add_ps(c, _mm256_set1_ps(0.734375f)); - __m256 r = _mm256_add_ps(nn, dd); - r = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x807FFFFF)), r); - r = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), r); - c = _mm256_add_ps(c, r); -} - -// 14*8 + 2 = 112 -inline void round_compute(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, const __m256& rnd_c, __m256& c, __m256& r) -{ - __m256 n = _mm256_setzero_ps(), d = _mm256_setzero_ps(); - - sub_round(n0, n1, n2, n3, rnd_c, n, d, c); - sub_round(n1, n2, n3, n0, rnd_c, n, d, c); - sub_round(n2, n3, n0, n1, rnd_c, n, d, c); - sub_round(n3, n0, n1, n2, rnd_c, n, d, c); - sub_round(n3, n2, n1, n0, rnd_c, n, d, c); - sub_round(n2, n1, n0, n3, rnd_c, n, d, c); - sub_round(n1, n0, n3, n2, rnd_c, n, d, c); - sub_round(n0, n3, n2, n1, rnd_c, n, d, c); - - // Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0 - d = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0xFF7FFFFF)), d); - d = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), d); - r = _mm256_add_ps(r, _mm256_div_ps(n, d)); -} - -// 112×4 = 448 -template -inline __m256i double_compute(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, - float lcnt, float hcnt, const __m256& rnd_c, __m256& sum) -{ - __m256 c = _mm256_insertf128_ps(_mm256_castps128_ps256(_mm_set1_ps(lcnt)), _mm_set1_ps(hcnt), 1); - __m256 r = _mm256_setzero_ps(); - - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - - // do a quick fmod by setting exp to 2 - r = _mm256_and_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x807FFFFF)), r); - r = _mm256_or_ps(_mm256_castsi256_ps(_mm256_set1_epi32(0x40000000)), r); - - if(add) - sum = _mm256_add_ps(sum, r); - else - sum = r; - - r = _mm256_mul_ps(r, _mm256_set1_ps(536870880.0f)); // 35 - return _mm256_cvttps_epi32(r); -} - -template -inline void double_compute_wrap(const __m256& n0, const __m256& n1, const __m256& n2, const __m256& n3, - float lcnt, float hcnt, const __m256& rnd_c, __m256& sum, __m256i& out) -{ - __m256i r = double_compute(n0, n1, n2, n3, lcnt, hcnt, rnd_c, sum); - if(rot != 0) - r = _mm256_or_si256(_mm256_bslli_epi128(r, 16 - rot), _mm256_bsrli_epi128(r, rot)); - - out = _mm256_xor_si256(out, r); -} - -template -inline __m256i* scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast<__m256i*>(lpad + (idx & MASK) + n*16); } - -template -void cn_gpu_inner_avx(const uint8_t* spad, uint8_t* lpad) -{ - uint32_t s = reinterpret_cast(spad)[0] >> 8; - __m256i* idx0 = scratchpad_ptr(lpad, s, 0); - __m256i* idx2 = scratchpad_ptr(lpad, s, 2); - __m256 sum0 = _mm256_setzero_ps(); - - for(size_t i = 0; i < ITER; i++) - { - __m256i v01, v23; - __m256 suma, sumb, sum1; - __m256 rc = sum0; - - __m256 n01, n23; - prep_dv_avx(idx0, v01, n01); - prep_dv_avx(idx2, v23, n23); - - __m256i out, out2; - __m256 n10, n22, n33; - n10 = _mm256_permute2f128_ps(n01, n01, 0x01); - n22 = _mm256_permute2f128_ps(n23, n23, 0x00); - n33 = _mm256_permute2f128_ps(n23, n23, 0x11); - - out = _mm256_setzero_si256(); - double_compute_wrap<0>(n01, n10, n22, n33, 1.3437500f, 1.4296875f, rc, suma, out); - double_compute_wrap<1>(n01, n22, n33, n10, 1.2812500f, 1.3984375f, rc, suma, out); - double_compute_wrap<2>(n01, n33, n10, n22, 1.3593750f, 1.3828125f, rc, sumb, out); - double_compute_wrap<3>(n01, n33, n22, n10, 1.3671875f, 1.3046875f, rc, sumb, out); - _mm256_store_si256(idx0, _mm256_xor_si256(v01, out)); - sum0 = _mm256_add_ps(suma, sumb); - out2 = out; - - __m256 n11, n02, n30; - n11 = _mm256_permute2f128_ps(n01, n01, 0x11); - n02 = _mm256_permute2f128_ps(n01, n23, 0x20); - n30 = _mm256_permute2f128_ps(n01, n23, 0x03); - - out = _mm256_setzero_si256(); - double_compute_wrap<0>(n23, n11, n02, n30, 1.4140625f, 1.3203125f, rc, suma, out); - double_compute_wrap<1>(n23, n02, n30, n11, 1.2734375f, 1.3515625f, rc, suma, out); - double_compute_wrap<2>(n23, n30, n11, n02, 1.2578125f, 1.3359375f, rc, sumb, out); - double_compute_wrap<3>(n23, n30, n02, n11, 1.2890625f, 1.4609375f, rc, sumb, out); - _mm256_store_si256(idx2, _mm256_xor_si256(v23, out)); - sum1 = _mm256_add_ps(suma, sumb); - - out2 = _mm256_xor_si256(out2, out); - out2 = _mm256_xor_si256(_mm256_permute2x128_si256(out2,out2,0x41), out2); - suma = _mm256_permute2f128_ps(sum0, sum1, 0x30); - sumb = _mm256_permute2f128_ps(sum0, sum1, 0x21); - sum0 = _mm256_add_ps(suma, sumb); - sum0 = _mm256_add_ps(sum0, _mm256_permute2f128_ps(sum0, sum0, 0x41)); - - // Clear the high 128 bits - __m128 sum = _mm256_castps256_ps128(sum0); - - sum = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)), sum); // take abs(va) by masking the float sign bit - // vs range 0 - 64 - __m128i v0 = _mm_cvttps_epi32(_mm_mul_ps(sum, _mm_set1_ps(16777216.0f))); - v0 = _mm_xor_si128(v0, _mm256_castsi256_si128(out2)); - __m128i v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 2, 3)); - v0 = _mm_xor_si128(v0, v1); - v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 0, 1)); - v0 = _mm_xor_si128(v0, v1); - - // vs is now between 0 and 1 - sum = _mm_div_ps(sum, _mm_set1_ps(64.0f)); - sum0 = _mm256_insertf128_ps(_mm256_castps128_ps256(sum), sum, 1); - uint32_t n = _mm_cvtsi128_si32(v0); - idx0 = scratchpad_ptr(lpad, n, 0); - idx2 = scratchpad_ptr(lpad, n, 2); - } -} - -template void cn_gpu_inner_avx(const uint8_t* spad, uint8_t* lpad); diff --git a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_ssse3.cpp b/src/Native/libcryptonight/xmrig/crypto/cn_gpu_ssse3.cpp deleted file mode 100644 index ce3d19addd..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/cn_gpu_ssse3.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2019 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "crypto/CryptoNight_constants.h" - -#ifdef __GNUC__ -# include -#else -# include -# define __restrict__ __restrict -#endif - -inline void prep_dv(__m128i* idx, __m128i& v, __m128& n) -{ - v = _mm_load_si128(idx); - n = _mm_cvtepi32_ps(v); -} - -inline __m128 fma_break(__m128 x) -{ - // Break the dependency chain by setitng the exp to ?????01 - x = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0xFEFFFFFF)), x); - return _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x00800000)), x); -} - -// 14 -inline void sub_round(__m128 n0, __m128 n1, __m128 n2, __m128 n3, __m128 rnd_c, __m128& n, __m128& d, __m128& c) -{ - n1 = _mm_add_ps(n1, c); - __m128 nn = _mm_mul_ps(n0, c); - nn = _mm_mul_ps(n1, _mm_mul_ps(nn,nn)); - nn = fma_break(nn); - n = _mm_add_ps(n, nn); - - n3 = _mm_sub_ps(n3, c); - __m128 dd = _mm_mul_ps(n2, c); - dd = _mm_mul_ps(n3, _mm_mul_ps(dd,dd)); - dd = fma_break(dd); - d = _mm_add_ps(d, dd); - - //Constant feedback - c = _mm_add_ps(c, rnd_c); - c = _mm_add_ps(c, _mm_set1_ps(0.734375f)); - __m128 r = _mm_add_ps(nn, dd); - r = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)), r); - r = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), r); - c = _mm_add_ps(c, r); -} - -// 14*8 + 2 = 112 -inline void round_compute(__m128 n0, __m128 n1, __m128 n2, __m128 n3, __m128 rnd_c, __m128& c, __m128& r) -{ - __m128 n = _mm_setzero_ps(), d = _mm_setzero_ps(); - - sub_round(n0, n1, n2, n3, rnd_c, n, d, c); - sub_round(n1, n2, n3, n0, rnd_c, n, d, c); - sub_round(n2, n3, n0, n1, rnd_c, n, d, c); - sub_round(n3, n0, n1, n2, rnd_c, n, d, c); - sub_round(n3, n2, n1, n0, rnd_c, n, d, c); - sub_round(n2, n1, n0, n3, rnd_c, n, d, c); - sub_round(n1, n0, n3, n2, rnd_c, n, d, c); - sub_round(n0, n3, n2, n1, rnd_c, n, d, c); - - // Make sure abs(d) > 2.0 - this prevents division by zero and accidental overflows by division by < 1.0 - d = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0xFF7FFFFF)), d); - d = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), d); - r =_mm_add_ps(r, _mm_div_ps(n,d)); -} - -// 112×4 = 448 -template -inline __m128i single_compute(__m128 n0, __m128 n1, __m128 n2, __m128 n3, float cnt, __m128 rnd_c, __m128& sum) -{ - __m128 c = _mm_set1_ps(cnt); - __m128 r = _mm_setzero_ps(); - - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - round_compute(n0, n1, n2, n3, rnd_c, c, r); - - // do a quick fmod by setting exp to 2 - r = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF)), r); - r = _mm_or_ps(_mm_castsi128_ps(_mm_set1_epi32(0x40000000)), r); - - if(add) - sum = _mm_add_ps(sum, r); - else - sum = r; - - r = _mm_mul_ps(r, _mm_set1_ps(536870880.0f)); // 35 - return _mm_cvttps_epi32(r); -} - -template -inline void single_compute_wrap(__m128 n0, __m128 n1, __m128 n2, __m128 n3, float cnt, __m128 rnd_c, __m128& sum, __m128i& out) -{ - __m128i r = single_compute(n0, n1, n2, n3, cnt, rnd_c, sum); - if(rot != 0) - r = _mm_or_si128(_mm_slli_si128(r, 16 - rot), _mm_srli_si128(r, rot)); - out = _mm_xor_si128(out, r); -} - -template -inline __m128i* scratchpad_ptr(uint8_t* lpad, uint32_t idx, size_t n) { return reinterpret_cast<__m128i*>(lpad + (idx & MASK) + n*16); } - -template -void cn_gpu_inner_ssse3(const uint8_t* spad, uint8_t* lpad) -{ - uint32_t s = reinterpret_cast(spad)[0] >> 8; - __m128i* idx0 = scratchpad_ptr(lpad, s, 0); - __m128i* idx1 = scratchpad_ptr(lpad, s, 1); - __m128i* idx2 = scratchpad_ptr(lpad, s, 2); - __m128i* idx3 = scratchpad_ptr(lpad, s, 3); - __m128 sum0 = _mm_setzero_ps(); - - for(size_t i = 0; i < ITER; i++) - { - __m128 n0, n1, n2, n3; - __m128i v0, v1, v2, v3; - __m128 suma, sumb, sum1, sum2, sum3; - - prep_dv(idx0, v0, n0); - prep_dv(idx1, v1, n1); - prep_dv(idx2, v2, n2); - prep_dv(idx3, v3, n3); - __m128 rc = sum0; - - __m128i out, out2; - out = _mm_setzero_si128(); - single_compute_wrap<0>(n0, n1, n2, n3, 1.3437500f, rc, suma, out); - single_compute_wrap<1>(n0, n2, n3, n1, 1.2812500f, rc, suma, out); - single_compute_wrap<2>(n0, n3, n1, n2, 1.3593750f, rc, sumb, out); - single_compute_wrap<3>(n0, n3, n2, n1, 1.3671875f, rc, sumb, out); - sum0 = _mm_add_ps(suma, sumb); - _mm_store_si128(idx0, _mm_xor_si128(v0, out)); - out2 = out; - - out = _mm_setzero_si128(); - single_compute_wrap<0>(n1, n0, n2, n3, 1.4296875f, rc, suma, out); - single_compute_wrap<1>(n1, n2, n3, n0, 1.3984375f, rc, suma, out); - single_compute_wrap<2>(n1, n3, n0, n2, 1.3828125f, rc, sumb, out); - single_compute_wrap<3>(n1, n3, n2, n0, 1.3046875f, rc, sumb, out); - sum1 = _mm_add_ps(suma, sumb); - _mm_store_si128(idx1, _mm_xor_si128(v1, out)); - out2 = _mm_xor_si128(out2, out); - - out = _mm_setzero_si128(); - single_compute_wrap<0>(n2, n1, n0, n3, 1.4140625f, rc, suma, out); - single_compute_wrap<1>(n2, n0, n3, n1, 1.2734375f, rc, suma, out); - single_compute_wrap<2>(n2, n3, n1, n0, 1.2578125f, rc, sumb, out); - single_compute_wrap<3>(n2, n3, n0, n1, 1.2890625f, rc, sumb, out); - sum2 = _mm_add_ps(suma, sumb); - _mm_store_si128(idx2, _mm_xor_si128(v2, out)); - out2 = _mm_xor_si128(out2, out); - - out = _mm_setzero_si128(); - single_compute_wrap<0>(n3, n1, n2, n0, 1.3203125f, rc, suma, out); - single_compute_wrap<1>(n3, n2, n0, n1, 1.3515625f, rc, suma, out); - single_compute_wrap<2>(n3, n0, n1, n2, 1.3359375f, rc, sumb, out); - single_compute_wrap<3>(n3, n0, n2, n1, 1.4609375f, rc, sumb, out); - sum3 = _mm_add_ps(suma, sumb); - _mm_store_si128(idx3, _mm_xor_si128(v3, out)); - out2 = _mm_xor_si128(out2, out); - sum0 = _mm_add_ps(sum0, sum1); - sum2 = _mm_add_ps(sum2, sum3); - sum0 = _mm_add_ps(sum0, sum2); - - sum0 = _mm_and_ps(_mm_castsi128_ps(_mm_set1_epi32(0x7fffffff)), sum0); // take abs(va) by masking the float sign bit - // vs range 0 - 64 - n0 = _mm_mul_ps(sum0, _mm_set1_ps(16777216.0f)); - v0 = _mm_cvttps_epi32(n0); - v0 = _mm_xor_si128(v0, out2); - v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 2, 3)); - v0 = _mm_xor_si128(v0, v1); - v1 = _mm_shuffle_epi32(v0, _MM_SHUFFLE(0, 1, 0, 1)); - v0 = _mm_xor_si128(v0, v1); - - // vs is now between 0 and 1 - sum0 = _mm_div_ps(sum0, _mm_set1_ps(64.0f)); - uint32_t n = _mm_cvtsi128_si32(v0); - idx0 = scratchpad_ptr(lpad, n, 0); - idx1 = scratchpad_ptr(lpad, n, 1); - idx2 = scratchpad_ptr(lpad, n, 2); - idx3 = scratchpad_ptr(lpad, n, 3); - } -} - -template void cn_gpu_inner_ssse3(const uint8_t* spad, uint8_t* lpad); diff --git a/src/Native/libcryptonight/xmrig/crypto/groestl_tables.h b/src/Native/libcryptonight/xmrig/crypto/groestl_tables.h deleted file mode 100644 index a23295c350..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/groestl_tables.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef __tables_h -#define __tables_h - - -const uint32_t T[512] = {0xa5f432c6, 0xc6a597f4, 0x84976ff8, 0xf884eb97, 0x99b05eee, 0xee99c7b0, 0x8d8c7af6, 0xf68df78c, 0xd17e8ff, 0xff0de517, 0xbddc0ad6, 0xd6bdb7dc, 0xb1c816de, 0xdeb1a7c8, 0x54fc6d91, 0x915439fc -, 0x50f09060, 0x6050c0f0, 0x3050702, 0x2030405, 0xa9e02ece, 0xcea987e0, 0x7d87d156, 0x567dac87, 0x192bcce7, 0xe719d52b, 0x62a613b5, 0xb56271a6, 0xe6317c4d, 0x4de69a31, 0x9ab559ec, 0xec9ac3b5 -, 0x45cf408f, 0x8f4505cf, 0x9dbca31f, 0x1f9d3ebc, 0x40c04989, 0x894009c0, 0x879268fa, 0xfa87ef92, 0x153fd0ef, 0xef15c53f, 0xeb2694b2, 0xb2eb7f26, 0xc940ce8e, 0x8ec90740, 0xb1de6fb, 0xfb0bed1d -, 0xec2f6e41, 0x41ec822f, 0x67a91ab3, 0xb3677da9, 0xfd1c435f, 0x5ffdbe1c, 0xea256045, 0x45ea8a25, 0xbfdaf923, 0x23bf46da, 0xf7025153, 0x53f7a602, 0x96a145e4, 0xe496d3a1, 0x5bed769b, 0x9b5b2ded -, 0xc25d2875, 0x75c2ea5d, 0x1c24c5e1, 0xe11cd924, 0xaee9d43d, 0x3dae7ae9, 0x6abef24c, 0x4c6a98be, 0x5aee826c, 0x6c5ad8ee, 0x41c3bd7e, 0x7e41fcc3, 0x206f3f5, 0xf502f106, 0x4fd15283, 0x834f1dd1 -, 0x5ce48c68, 0x685cd0e4, 0xf4075651, 0x51f4a207, 0x345c8dd1, 0xd134b95c, 0x818e1f9, 0xf908e918, 0x93ae4ce2, 0xe293dfae, 0x73953eab, 0xab734d95, 0x53f59762, 0x6253c4f5, 0x3f416b2a, 0x2a3f5441 -, 0xc141c08, 0x80c1014, 0x52f66395, 0x955231f6, 0x65afe946, 0x46658caf, 0x5ee27f9d, 0x9d5e21e2, 0x28784830, 0x30286078, 0xa1f8cf37, 0x37a16ef8, 0xf111b0a, 0xa0f1411, 0xb5c4eb2f, 0x2fb55ec4 -, 0x91b150e, 0xe091c1b, 0x365a7e24, 0x2436485a, 0x9bb6ad1b, 0x1b9b36b6, 0x3d4798df, 0xdf3da547, 0x266aa7cd, 0xcd26816a, 0x69bbf54e, 0x4e699cbb, 0xcd4c337f, 0x7fcdfe4c, 0x9fba50ea, 0xea9fcfba -, 0x1b2d3f12, 0x121b242d, 0x9eb9a41d, 0x1d9e3ab9, 0x749cc458, 0x5874b09c, 0x2e724634, 0x342e6872, 0x2d774136, 0x362d6c77, 0xb2cd11dc, 0xdcb2a3cd, 0xee299db4, 0xb4ee7329, 0xfb164d5b, 0x5bfbb616 -, 0xf601a5a4, 0xa4f65301, 0x4dd7a176, 0x764decd7, 0x61a314b7, 0xb76175a3, 0xce49347d, 0x7dcefa49, 0x7b8ddf52, 0x527ba48d, 0x3e429fdd, 0xdd3ea142, 0x7193cd5e, 0x5e71bc93, 0x97a2b113, 0x139726a2 -, 0xf504a2a6, 0xa6f55704, 0x68b801b9, 0xb96869b8, 0x0, 0x0, 0x2c74b5c1, 0xc12c9974, 0x60a0e040, 0x406080a0, 0x1f21c2e3, 0xe31fdd21, 0xc8433a79, 0x79c8f243, 0xed2c9ab6, 0xb6ed772c -, 0xbed90dd4, 0xd4beb3d9, 0x46ca478d, 0x8d4601ca, 0xd9701767, 0x67d9ce70, 0x4bddaf72, 0x724be4dd, 0xde79ed94, 0x94de3379, 0xd467ff98, 0x98d42b67, 0xe82393b0, 0xb0e87b23, 0x4ade5b85, 0x854a11de -, 0x6bbd06bb, 0xbb6b6dbd, 0x2a7ebbc5, 0xc52a917e, 0xe5347b4f, 0x4fe59e34, 0x163ad7ed, 0xed16c13a, 0xc554d286, 0x86c51754, 0xd762f89a, 0x9ad72f62, 0x55ff9966, 0x6655ccff, 0x94a7b611, 0x119422a7 -, 0xcf4ac08a, 0x8acf0f4a, 0x1030d9e9, 0xe910c930, 0x60a0e04, 0x406080a, 0x819866fe, 0xfe81e798, 0xf00baba0, 0xa0f05b0b, 0x44ccb478, 0x7844f0cc, 0xbad5f025, 0x25ba4ad5, 0xe33e754b, 0x4be3963e -, 0xf30eaca2, 0xa2f35f0e, 0xfe19445d, 0x5dfeba19, 0xc05bdb80, 0x80c01b5b, 0x8a858005, 0x58a0a85, 0xadecd33f, 0x3fad7eec, 0xbcdffe21, 0x21bc42df, 0x48d8a870, 0x7048e0d8, 0x40cfdf1, 0xf104f90c -, 0xdf7a1963, 0x63dfc67a, 0xc1582f77, 0x77c1ee58, 0x759f30af, 0xaf75459f, 0x63a5e742, 0x426384a5, 0x30507020, 0x20304050, 0x1a2ecbe5, 0xe51ad12e, 0xe12effd, 0xfd0ee112, 0x6db708bf, 0xbf6d65b7 -, 0x4cd45581, 0x814c19d4, 0x143c2418, 0x1814303c, 0x355f7926, 0x26354c5f, 0x2f71b2c3, 0xc32f9d71, 0xe13886be, 0xbee16738, 0xa2fdc835, 0x35a26afd, 0xcc4fc788, 0x88cc0b4f, 0x394b652e, 0x2e395c4b -, 0x57f96a93, 0x93573df9, 0xf20d5855, 0x55f2aa0d, 0x829d61fc, 0xfc82e39d, 0x47c9b37a, 0x7a47f4c9, 0xacef27c8, 0xc8ac8bef, 0xe73288ba, 0xbae76f32, 0x2b7d4f32, 0x322b647d, 0x95a442e6, 0xe695d7a4 -, 0xa0fb3bc0, 0xc0a09bfb, 0x98b3aa19, 0x199832b3, 0xd168f69e, 0x9ed12768, 0x7f8122a3, 0xa37f5d81, 0x66aaee44, 0x446688aa, 0x7e82d654, 0x547ea882, 0xabe6dd3b, 0x3bab76e6, 0x839e950b, 0xb83169e -, 0xca45c98c, 0x8cca0345, 0x297bbcc7, 0xc729957b, 0xd36e056b, 0x6bd3d66e, 0x3c446c28, 0x283c5044, 0x798b2ca7, 0xa779558b, 0xe23d81bc, 0xbce2633d, 0x1d273116, 0x161d2c27, 0x769a37ad, 0xad76419a -, 0x3b4d96db, 0xdb3bad4d, 0x56fa9e64, 0x6456c8fa, 0x4ed2a674, 0x744ee8d2, 0x1e223614, 0x141e2822, 0xdb76e492, 0x92db3f76, 0xa1e120c, 0xc0a181e, 0x6cb4fc48, 0x486c90b4, 0xe4378fb8, 0xb8e46b37 -, 0x5de7789f, 0x9f5d25e7, 0x6eb20fbd, 0xbd6e61b2, 0xef2a6943, 0x43ef862a, 0xa6f135c4, 0xc4a693f1, 0xa8e3da39, 0x39a872e3, 0xa4f7c631, 0x31a462f7, 0x37598ad3, 0xd337bd59, 0x8b8674f2, 0xf28bff86 -, 0x325683d5, 0xd532b156, 0x43c54e8b, 0x8b430dc5, 0x59eb856e, 0x6e59dceb, 0xb7c218da, 0xdab7afc2, 0x8c8f8e01, 0x18c028f, 0x64ac1db1, 0xb16479ac, 0xd26df19c, 0x9cd2236d, 0xe03b7249, 0x49e0923b -, 0xb4c71fd8, 0xd8b4abc7, 0xfa15b9ac, 0xacfa4315, 0x709faf3, 0xf307fd09, 0x256fa0cf, 0xcf25856f, 0xafea20ca, 0xcaaf8fea, 0x8e897df4, 0xf48ef389, 0xe9206747, 0x47e98e20, 0x18283810, 0x10182028 -, 0xd5640b6f, 0x6fd5de64, 0x888373f0, 0xf088fb83, 0x6fb1fb4a, 0x4a6f94b1, 0x7296ca5c, 0x5c72b896, 0x246c5438, 0x3824706c, 0xf1085f57, 0x57f1ae08, 0xc7522173, 0x73c7e652, 0x51f36497, 0x975135f3 -, 0x2365aecb, 0xcb238d65, 0x7c8425a1, 0xa17c5984, 0x9cbf57e8, 0xe89ccbbf, 0x21635d3e, 0x3e217c63, 0xdd7cea96, 0x96dd377c, 0xdc7f1e61, 0x61dcc27f, 0x86919c0d, 0xd861a91, 0x85949b0f, 0xf851e94 -, 0x90ab4be0, 0xe090dbab, 0x42c6ba7c, 0x7c42f8c6, 0xc4572671, 0x71c4e257, 0xaae529cc, 0xccaa83e5, 0xd873e390, 0x90d83b73, 0x50f0906, 0x6050c0f, 0x103f4f7, 0xf701f503, 0x12362a1c, 0x1c123836 -, 0xa3fe3cc2, 0xc2a39ffe, 0x5fe18b6a, 0x6a5fd4e1, 0xf910beae, 0xaef94710, 0xd06b0269, 0x69d0d26b, 0x91a8bf17, 0x17912ea8, 0x58e87199, 0x995829e8, 0x2769533a, 0x3a277469, 0xb9d0f727, 0x27b94ed0 -, 0x384891d9, 0xd938a948, 0x1335deeb, 0xeb13cd35, 0xb3cee52b, 0x2bb356ce, 0x33557722, 0x22334455, 0xbbd604d2, 0xd2bbbfd6, 0x709039a9, 0xa9704990, 0x89808707, 0x7890e80, 0xa7f2c133, 0x33a766f2 -, 0xb6c1ec2d, 0x2db65ac1, 0x22665a3c, 0x3c227866, 0x92adb815, 0x15922aad, 0x2060a9c9, 0xc9208960, 0x49db5c87, 0x874915db, 0xff1ab0aa, 0xaaff4f1a, 0x7888d850, 0x5078a088, 0x7a8e2ba5, 0xa57a518e -, 0x8f8a8903, 0x38f068a, 0xf8134a59, 0x59f8b213, 0x809b9209, 0x980129b, 0x1739231a, 0x1a173439, 0xda751065, 0x65daca75, 0x315384d7, 0xd731b553, 0xc651d584, 0x84c61351, 0xb8d303d0, 0xd0b8bbd3 -, 0xc35edc82, 0x82c31f5e, 0xb0cbe229, 0x29b052cb, 0x7799c35a, 0x5a77b499, 0x11332d1e, 0x1e113c33, 0xcb463d7b, 0x7bcbf646, 0xfc1fb7a8, 0xa8fc4b1f, 0xd6610c6d, 0x6dd6da61, 0x3a4e622c, 0x2c3a584e}; - -#endif /* __tables_h */ diff --git a/src/Native/libcryptonight/xmrig/crypto/hash.h b/src/Native/libcryptonight/xmrig/crypto/hash.h deleted file mode 100644 index c12d355f49..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/hash.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -typedef unsigned char BitSequence; -typedef unsigned long long DataLength; -typedef enum {SUCCESS = 0, FAIL = 1, BAD_HASHLEN = 2} HashReturn; diff --git a/src/Native/libcryptonight/xmrig/crypto/skein_port.h b/src/Native/libcryptonight/xmrig/crypto/skein_port.h deleted file mode 100644 index 4b521c7cf7..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/skein_port.h +++ /dev/null @@ -1,187 +0,0 @@ -#ifndef _SKEIN_PORT_H_ -#define _SKEIN_PORT_H_ - -#include -#include - -#ifndef RETURN_VALUES -# define RETURN_VALUES -# if defined( DLL_EXPORT ) -# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllexport ) void __stdcall -# define INT_RETURN __declspec( dllexport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllexport__ ) void -# define INT_RETURN __declspec( __dllexport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( DLL_IMPORT ) -# if defined( _MSC_VER ) || defined ( __INTEL_COMPILER ) -# define VOID_RETURN __declspec( dllimport ) void __stdcall -# define INT_RETURN __declspec( dllimport ) int __stdcall -# elif defined( __GNUC__ ) -# define VOID_RETURN __declspec( __dllimport__ ) void -# define INT_RETURN __declspec( __dllimport__ ) int -# else -# error Use of the DLL is only available on the Microsoft, Intel and GCC compilers -# endif -# elif defined( __WATCOMC__ ) -# define VOID_RETURN void __cdecl -# define INT_RETURN int __cdecl -# else -# define VOID_RETURN void -# define INT_RETURN int -# endif -#endif - -/* These defines are used to declare buffers in a way that allows - faster operations on longer variables to be used. In all these - defines 'size' must be a power of 2 and >= 8 - - dec_unit_type(size,x) declares a variable 'x' of length - 'size' bits - - dec_bufr_type(size,bsize,x) declares a buffer 'x' of length 'bsize' - bytes defined as an array of variables - each of 'size' bits (bsize must be a - multiple of size / 8) - - ptr_cast(x,size) casts a pointer to a pointer to a - varaiable of length 'size' bits -*/ - -#define ui_type(size) uint##size##_t -#define dec_unit_type(size,x) typedef ui_type(size) x -#define dec_bufr_type(size,bsize,x) typedef ui_type(size) x[bsize / (size >> 3)] -#define ptr_cast(x,size) ((ui_type(size)*)(x)) - -typedef unsigned int uint_t; /* native unsigned integer */ -typedef uint8_t u08b_t; /* 8-bit unsigned integer */ -typedef uint64_t u64b_t; /* 64-bit unsigned integer */ - -#ifndef RotL_64 -#define RotL_64(x,N) (((x) << (N)) | ((x) >> (64-(N)))) -#endif - -/* - * Skein is "natively" little-endian (unlike SHA-xxx), for optimal - * performance on x86 CPUs. The Skein code requires the following - * definitions for dealing with endianness: - * - * SKEIN_NEED_SWAP: 0 for little-endian, 1 for big-endian - * Skein_Put64_LSB_First - * Skein_Get64_LSB_First - * Skein_Swap64 - * - * If SKEIN_NEED_SWAP is defined at compile time, it is used here - * along with the portable versions of Put64/Get64/Swap64, which - * are slow in general. - * - * Otherwise, an "auto-detect" of endianness is attempted below. - * If the default handling doesn't work well, the user may insert - * platform-specific code instead (e.g., for big-endian CPUs). - * - */ -#ifndef SKEIN_NEED_SWAP /* compile-time "override" for endianness? */ - -#define IS_BIG_ENDIAN 4321 /* byte 0 is most significant (mc68k) */ -#define IS_LITTLE_ENDIAN 1234 /* byte 0 is least significant (i386) */ - -#if BYTE_ORDER == LITTLE_ENDIAN && !defined(PLATFORM_BYTE_ORDER) -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif - -#if BYTE_ORDER == BIG_ENDIAN && !defined(PLATFORM_BYTE_ORDER) -# define PLATFORM_BYTE_ORDER IS_BIG_ENDIAN -#endif - -/* special handler for IA64, which may be either endianness (?) */ -/* here we assume little-endian, but this may need to be changed */ -#if defined(__ia64) || defined(__ia64__) || defined(_M_IA64) -# define PLATFORM_MUST_ALIGN (1) -#ifndef PLATFORM_BYTE_ORDER -# define PLATFORM_BYTE_ORDER IS_LITTLE_ENDIAN -#endif -#endif - -#ifndef PLATFORM_MUST_ALIGN -# define PLATFORM_MUST_ALIGN (0) -#endif - - -#if PLATFORM_BYTE_ORDER == IS_BIG_ENDIAN - /* here for big-endian CPUs */ -#define SKEIN_NEED_SWAP (1) -#elif PLATFORM_BYTE_ORDER == IS_LITTLE_ENDIAN - /* here for x86 and x86-64 CPUs (and other detected little-endian CPUs) */ -#define SKEIN_NEED_SWAP (0) -#if PLATFORM_MUST_ALIGN == 0 /* ok to use "fast" versions? */ -#define Skein_Put64_LSB_First(dst08,src64,bCnt) memcpy(dst08,src64,bCnt) -#define Skein_Get64_LSB_First(dst64,src08,wCnt) memcpy(dst64,src08,8*(wCnt)) -#endif -#else -#error "Skein needs endianness setting!" -#endif - -#endif /* ifndef SKEIN_NEED_SWAP */ - -/* - ****************************************************************** - * Provide any definitions still needed. - ****************************************************************** - */ -#ifndef Skein_Swap64 /* swap for big-endian, nop for little-endian */ -#if SKEIN_NEED_SWAP -#define Skein_Swap64(w64) \ - ( (( ((u64b_t)(w64)) & 0xFF) << 56) | \ - (((((u64b_t)(w64)) >> 8) & 0xFF) << 48) | \ - (((((u64b_t)(w64)) >>16) & 0xFF) << 40) | \ - (((((u64b_t)(w64)) >>24) & 0xFF) << 32) | \ - (((((u64b_t)(w64)) >>32) & 0xFF) << 24) | \ - (((((u64b_t)(w64)) >>40) & 0xFF) << 16) | \ - (((((u64b_t)(w64)) >>48) & 0xFF) << 8) | \ - (((((u64b_t)(w64)) >>56) & 0xFF) ) ) -#else -#define Skein_Swap64(w64) (w64) -#endif -#endif /* ifndef Skein_Swap64 */ - - -#ifndef Skein_Put64_LSB_First -void Skein_Put64_LSB_First(u08b_t *dst,const u64b_t *src,size_t bCnt) -#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ - { /* this version is fully portable (big-endian or little-endian), but slow */ - size_t n; - - for (n=0;n>3] >> (8*(n&7))); - } -#else - ; /* output only the function prototype */ -#endif -#endif /* ifndef Skein_Put64_LSB_First */ - - -#ifndef Skein_Get64_LSB_First -void Skein_Get64_LSB_First(u64b_t *dst,const u08b_t *src,size_t wCnt) -#ifdef SKEIN_PORT_CODE /* instantiate the function code here? */ - { /* this version is fully portable (big-endian or little-endian), but slow */ - size_t n; - - for (n=0;n<8*wCnt;n+=8) - dst[n/8] = (((u64b_t) src[n ]) ) + - (((u64b_t) src[n+1]) << 8) + - (((u64b_t) src[n+2]) << 16) + - (((u64b_t) src[n+3]) << 24) + - (((u64b_t) src[n+4]) << 32) + - (((u64b_t) src[n+5]) << 40) + - (((u64b_t) src[n+6]) << 48) + - (((u64b_t) src[n+7]) << 56) ; - } -#else - ; /* output only the function prototype */ -#endif -#endif /* ifndef Skein_Get64_LSB_First */ - -#endif /* ifndef _SKEIN_PORT_H_ */ diff --git a/src/Native/libcryptonight/xmrig/crypto/soft_aes.h b/src/Native/libcryptonight/xmrig/crypto/soft_aes.h deleted file mode 100644 index 26c1b06ade..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/soft_aes.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * Additional permission under GNU GPL version 3 section 7 - * - * If you modify this Program, or any covered work, by linking or combining - * it with OpenSSL (or a modified version of that library), containing parts - * covered by the terms of OpenSSL License and SSLeay License, the licensors - * of this Program grant you additional permission to convey the resulting work. - * - */ - -/* - * Parts of this file are originally copyright (c) 2014-2017, The Monero Project - */ -#pragma once - - -#if defined(XMRIG_ARM) -# include "crypto/SSE2NEON.h" -#elif defined(__GNUC__) -# include -#else -# include -#endif - -#include - - -#define saes_data(w) {\ - w(0x63), w(0x7c), w(0x77), w(0x7b), w(0xf2), w(0x6b), w(0x6f), w(0xc5),\ - w(0x30), w(0x01), w(0x67), w(0x2b), w(0xfe), w(0xd7), w(0xab), w(0x76),\ - w(0xca), w(0x82), w(0xc9), w(0x7d), w(0xfa), w(0x59), w(0x47), w(0xf0),\ - w(0xad), w(0xd4), w(0xa2), w(0xaf), w(0x9c), w(0xa4), w(0x72), w(0xc0),\ - w(0xb7), w(0xfd), w(0x93), w(0x26), w(0x36), w(0x3f), w(0xf7), w(0xcc),\ - w(0x34), w(0xa5), w(0xe5), w(0xf1), w(0x71), w(0xd8), w(0x31), w(0x15),\ - w(0x04), w(0xc7), w(0x23), w(0xc3), w(0x18), w(0x96), w(0x05), w(0x9a),\ - w(0x07), w(0x12), w(0x80), w(0xe2), w(0xeb), w(0x27), w(0xb2), w(0x75),\ - w(0x09), w(0x83), w(0x2c), w(0x1a), w(0x1b), w(0x6e), w(0x5a), w(0xa0),\ - w(0x52), w(0x3b), w(0xd6), w(0xb3), w(0x29), w(0xe3), w(0x2f), w(0x84),\ - w(0x53), w(0xd1), w(0x00), w(0xed), w(0x20), w(0xfc), w(0xb1), w(0x5b),\ - w(0x6a), w(0xcb), w(0xbe), w(0x39), w(0x4a), w(0x4c), w(0x58), w(0xcf),\ - w(0xd0), w(0xef), w(0xaa), w(0xfb), w(0x43), w(0x4d), w(0x33), w(0x85),\ - w(0x45), w(0xf9), w(0x02), w(0x7f), w(0x50), w(0x3c), w(0x9f), w(0xa8),\ - w(0x51), w(0xa3), w(0x40), w(0x8f), w(0x92), w(0x9d), w(0x38), w(0xf5),\ - w(0xbc), w(0xb6), w(0xda), w(0x21), w(0x10), w(0xff), w(0xf3), w(0xd2),\ - w(0xcd), w(0x0c), w(0x13), w(0xec), w(0x5f), w(0x97), w(0x44), w(0x17),\ - w(0xc4), w(0xa7), w(0x7e), w(0x3d), w(0x64), w(0x5d), w(0x19), w(0x73),\ - w(0x60), w(0x81), w(0x4f), w(0xdc), w(0x22), w(0x2a), w(0x90), w(0x88),\ - w(0x46), w(0xee), w(0xb8), w(0x14), w(0xde), w(0x5e), w(0x0b), w(0xdb),\ - w(0xe0), w(0x32), w(0x3a), w(0x0a), w(0x49), w(0x06), w(0x24), w(0x5c),\ - w(0xc2), w(0xd3), w(0xac), w(0x62), w(0x91), w(0x95), w(0xe4), w(0x79),\ - w(0xe7), w(0xc8), w(0x37), w(0x6d), w(0x8d), w(0xd5), w(0x4e), w(0xa9),\ - w(0x6c), w(0x56), w(0xf4), w(0xea), w(0x65), w(0x7a), w(0xae), w(0x08),\ - w(0xba), w(0x78), w(0x25), w(0x2e), w(0x1c), w(0xa6), w(0xb4), w(0xc6),\ - w(0xe8), w(0xdd), w(0x74), w(0x1f), w(0x4b), w(0xbd), w(0x8b), w(0x8a),\ - w(0x70), w(0x3e), w(0xb5), w(0x66), w(0x48), w(0x03), w(0xf6), w(0x0e),\ - w(0x61), w(0x35), w(0x57), w(0xb9), w(0x86), w(0xc1), w(0x1d), w(0x9e),\ - w(0xe1), w(0xf8), w(0x98), w(0x11), w(0x69), w(0xd9), w(0x8e), w(0x94),\ - w(0x9b), w(0x1e), w(0x87), w(0xe9), w(0xce), w(0x55), w(0x28), w(0xdf),\ - w(0x8c), w(0xa1), w(0x89), w(0x0d), w(0xbf), w(0xe6), w(0x42), w(0x68),\ - w(0x41), w(0x99), w(0x2d), w(0x0f), w(0xb0), w(0x54), w(0xbb), w(0x16) } - -#define SAES_WPOLY 0x011b - -#define saes_b2w(b0, b1, b2, b3) (((uint32_t)(b3) << 24) | \ - ((uint32_t)(b2) << 16) | ((uint32_t)(b1) << 8) | (b0)) - -#define saes_f2(x) ((x<<1) ^ (((x>>7) & 1) * SAES_WPOLY)) -#define saes_f3(x) (saes_f2(x) ^ x) -#define saes_h0(x) (x) - -#define saes_u0(p) saes_b2w(saes_f2(p), p, p, saes_f3(p)) -#define saes_u1(p) saes_b2w(saes_f3(p), saes_f2(p), p, p) -#define saes_u2(p) saes_b2w( p, saes_f3(p), saes_f2(p), p) -#define saes_u3(p) saes_b2w( p, p, saes_f3(p), saes_f2(p)) - -alignas(16) const uint32_t saes_table[4][256] = { saes_data(saes_u0), saes_data(saes_u1), saes_data(saes_u2), saes_data(saes_u3) }; -alignas(16) const uint8_t saes_sbox[256] = saes_data(saes_h0); - -static inline __m128i soft_aesenc(const uint32_t* in, __m128i key) -{ - const uint32_t x0 = in[0]; - const uint32_t x1 = in[1]; - const uint32_t x2 = in[2]; - const uint32_t x3 = in[3]; - - __m128i out = _mm_set_epi32( - (saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^ saes_table[3][x2 >> 24]), - (saes_table[0][x2 & 0xff] ^ saes_table[1][(x3 >> 8) & 0xff] ^ saes_table[2][(x0 >> 16) & 0xff] ^ saes_table[3][x1 >> 24]), - (saes_table[0][x1 & 0xff] ^ saes_table[1][(x2 >> 8) & 0xff] ^ saes_table[2][(x3 >> 16) & 0xff] ^ saes_table[3][x0 >> 24]), - (saes_table[0][x0 & 0xff] ^ saes_table[1][(x1 >> 8) & 0xff] ^ saes_table[2][(x2 >> 16) & 0xff] ^ saes_table[3][x3 >> 24])); - - return _mm_xor_si128(out, key); -} - -static inline __m128i soft_aesenc(__m128i in, __m128i key) -{ - uint32_t x0, x1, x2, x3; - x0 = _mm_cvtsi128_si32(in); - x1 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0x55)); - x2 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xAA)); - x3 = _mm_cvtsi128_si32(_mm_shuffle_epi32(in, 0xFF)); - - __m128i out = _mm_set_epi32( - (saes_table[0][x3 & 0xff] ^ saes_table[1][(x0 >> 8) & 0xff] ^ saes_table[2][(x1 >> 16) & 0xff] ^ saes_table[3][x2 >> 24]), - (saes_table[0][x2 & 0xff] ^ saes_table[1][(x3 >> 8) & 0xff] ^ saes_table[2][(x0 >> 16) & 0xff] ^ saes_table[3][x1 >> 24]), - (saes_table[0][x1 & 0xff] ^ saes_table[1][(x2 >> 8) & 0xff] ^ saes_table[2][(x3 >> 16) & 0xff] ^ saes_table[3][x0 >> 24]), - (saes_table[0][x0 & 0xff] ^ saes_table[1][(x1 >> 8) & 0xff] ^ saes_table[2][(x2 >> 16) & 0xff] ^ saes_table[3][x3 >> 24])); - - return _mm_xor_si128(out, key); -} - -static inline uint32_t sub_word(uint32_t key) -{ - return (saes_sbox[key >> 24 ] << 24) | - (saes_sbox[(key >> 16) & 0xff] << 16 ) | - (saes_sbox[(key >> 8) & 0xff] << 8 ) | - saes_sbox[key & 0xff]; -} - -#if defined(__clang__) || defined(XMRIG_ARM) -static inline uint32_t _rotr(uint32_t value, uint32_t amount) -{ - return (value >> amount) | (value << ((32 - amount) & 31)); -} -#endif - -template -static inline __m128i soft_aeskeygenassist(__m128i key) -{ - const uint32_t X1 = sub_word(_mm_cvtsi128_si32(_mm_shuffle_epi32(key, 0x55))); - const uint32_t X3 = sub_word(_mm_cvtsi128_si32(_mm_shuffle_epi32(key, 0xFF))); - return _mm_set_epi32(_rotr(X3, 8) ^ rcon, X3, _rotr(X1, 8) ^ rcon, X1); -} diff --git a/src/Native/libcryptonight/xmrig/crypto/variant4_random_math.h b/src/Native/libcryptonight/xmrig/crypto/variant4_random_math.h deleted file mode 100644 index 1f3ea0ac3e..0000000000 --- a/src/Native/libcryptonight/xmrig/crypto/variant4_random_math.h +++ /dev/null @@ -1,448 +0,0 @@ -#ifndef VARIANT4_RANDOM_MATH_H -#define VARIANT4_RANDOM_MATH_H - -extern "C" -{ - #include "c_blake256.h" -} - -enum V4_Settings -{ - // Generate code with minimal theoretical latency = 45 cycles, which is equivalent to 15 multiplications - TOTAL_LATENCY = 15 * 3, - - // Always generate at least 60 instructions - NUM_INSTRUCTIONS_MIN = 60, - - // Never generate more than 70 instructions (final RET instruction doesn't count here) - NUM_INSTRUCTIONS_MAX = 70, - - // Available ALUs for MUL - // Modern CPUs typically have only 1 ALU which can do multiplications - ALU_COUNT_MUL = 1, - - // Total available ALUs - // Modern CPUs have 4 ALUs, but we use only 3 because random math executes together with other main loop code - ALU_COUNT = 3, -}; - -enum V4_InstructionList -{ - MUL, // a*b - ADD, // a+b + C, C is an unsigned 32-bit constant - SUB, // a-b - ROR, // rotate right "a" by "b & 31" bits - ROL, // rotate left "a" by "b & 31" bits - XOR, // a^b - RET, // finish execution - V4_INSTRUCTION_COUNT = RET, -}; - -// V4_InstructionDefinition is used to generate code from random data -// Every random sequence of bytes is a valid code -// -// There are 9 registers in total: -// - 4 variable registers -// - 5 constant registers initialized from loop variables -// This is why dst_index is 2 bits -enum V4_InstructionDefinition -{ - V4_OPCODE_BITS = 3, - V4_DST_INDEX_BITS = 2, - V4_SRC_INDEX_BITS = 3, -}; - -struct V4_Instruction -{ - uint8_t opcode; - uint8_t dst_index; - uint8_t src_index; - uint32_t C; -}; - -#ifndef FORCEINLINE -#ifdef __GNUC__ -#define FORCEINLINE __attribute__((always_inline)) inline -#elif _MSC_VER -#define FORCEINLINE __forceinline -#else -#define FORCEINLINE inline -#endif -#endif - -#ifndef UNREACHABLE_CODE -#ifdef __GNUC__ -#define UNREACHABLE_CODE __builtin_unreachable() -#elif _MSC_VER -#define UNREACHABLE_CODE __assume(false) -#else -#define UNREACHABLE_CODE -#endif -#endif - -// Random math interpreter's loop is fully unrolled and inlined to achieve 100% branch prediction on CPU: -// every switch-case will point to the same destination on every iteration of Cryptonight main loop -// -// This is about as fast as it can get without using low-level machine code generation -template -static void v4_random_math(const struct V4_Instruction* code, v4_reg* r) -{ - enum - { - REG_BITS = sizeof(v4_reg) * 8, - }; - -#define V4_EXEC(i) \ - { \ - const struct V4_Instruction* op = code + i; \ - const v4_reg src = r[op->src_index]; \ - v4_reg* dst = r + op->dst_index; \ - switch (op->opcode) \ - { \ - case MUL: \ - *dst *= src; \ - break; \ - case ADD: \ - *dst += src + op->C; \ - break; \ - case SUB: \ - *dst -= src; \ - break; \ - case ROR: \ - { \ - const uint32_t shift = src % REG_BITS; \ - *dst = (*dst >> shift) | (*dst << ((REG_BITS - shift) % REG_BITS)); \ - } \ - break; \ - case ROL: \ - { \ - const uint32_t shift = src % REG_BITS; \ - *dst = (*dst << shift) | (*dst >> ((REG_BITS - shift) % REG_BITS)); \ - } \ - break; \ - case XOR: \ - *dst ^= src; \ - break; \ - case RET: \ - return; \ - default: \ - UNREACHABLE_CODE; \ - break; \ - } \ - } - -#define V4_EXEC_10(j) \ - V4_EXEC(j + 0) \ - V4_EXEC(j + 1) \ - V4_EXEC(j + 2) \ - V4_EXEC(j + 3) \ - V4_EXEC(j + 4) \ - V4_EXEC(j + 5) \ - V4_EXEC(j + 6) \ - V4_EXEC(j + 7) \ - V4_EXEC(j + 8) \ - V4_EXEC(j + 9) - - // Generated program can have 60 + a few more (usually 2-3) instructions to achieve required latency - // I've checked all block heights < 10,000,000 and here is the distribution of program sizes: - // - // 60 27960 - // 61 105054 - // 62 2452759 - // 63 5115997 - // 64 1022269 - // 65 1109635 - // 66 153145 - // 67 8550 - // 68 4529 - // 69 102 - - // Unroll 70 instructions here - V4_EXEC_10(0); // instructions 0-9 - V4_EXEC_10(10); // instructions 10-19 - V4_EXEC_10(20); // instructions 20-29 - V4_EXEC_10(30); // instructions 30-39 - V4_EXEC_10(40); // instructions 40-49 - V4_EXEC_10(50); // instructions 50-59 - V4_EXEC_10(60); // instructions 60-69 - -#undef V4_EXEC_10 -#undef V4_EXEC -} - -// If we don't have enough data available, generate more -static FORCEINLINE void check_data(size_t* data_index, const size_t bytes_needed, int8_t* data, const size_t data_size) -{ - if (*data_index + bytes_needed > data_size) - { - hash_extra_blake(data, data_size, (char*) data); - *data_index = 0; - } -} - -// Generates as many random math operations as possible with given latency and ALU restrictions -// "code" array must have space for NUM_INSTRUCTIONS_MAX+1 instructions -template -static int v4_random_math_init(struct V4_Instruction* code, const uint64_t height) -{ - // MUL is 3 cycles, 3-way addition and rotations are 2 cycles, SUB/XOR are 1 cycle - // These latencies match real-life instruction latencies for Intel CPUs starting from Sandy Bridge and up to Skylake/Coffee lake - // - // AMD Ryzen has the same latencies except 1-cycle ROR/ROL, so it'll be a bit faster than Intel Sandy Bridge and newer processors - // Surprisingly, Intel Nehalem also has 1-cycle ROR/ROL, so it'll also be faster than Intel Sandy Bridge and newer processors - // AMD Bulldozer has 4 cycles latency for MUL (slower than Intel) and 1 cycle for ROR/ROL (faster than Intel), so average performance will be the same - // Source: https://www.agner.org/optimize/instruction_tables.pdf - const int op_latency[V4_INSTRUCTION_COUNT] = { 3, 2, 1, 2, 2, 1 }; - - // Instruction latencies for theoretical ASIC implementation - const int asic_op_latency[V4_INSTRUCTION_COUNT] = { 3, 1, 1, 1, 1, 1 }; - - // Available ALUs for each instruction - const int op_ALUs[V4_INSTRUCTION_COUNT] = { ALU_COUNT_MUL, ALU_COUNT, ALU_COUNT, ALU_COUNT, ALU_COUNT, ALU_COUNT }; - - int8_t data[32]; - memset(data, 0, sizeof(data)); - uint64_t tmp = SWAP64LE(height); - memcpy(data, &tmp, sizeof(uint64_t)); - if (VARIANT == xmrig::VARIANT_4) - { - data[20] = -38; - } - - // Set data_index past the last byte in data - // to trigger full data update with blake hash - // before we start using it - size_t data_index = sizeof(data); - - int code_size; - - // There is a small chance (1.8%) that register R8 won't be used in the generated program - // So we keep track of it and try again if it's not used - bool r8_used; - do { - int latency[9]; - int asic_latency[9]; - - // Tracks previous instruction and value of the source operand for registers R0-R3 throughout code execution - // byte 0: current value of the destination register - // byte 1: instruction opcode - // byte 2: current value of the source register - // - // Registers R4-R8 are constant and are treated as having the same value because when we do - // the same operation twice with two constant source registers, it can be optimized into a single operation - uint32_t inst_data[9] = { 0, 1, 2, 3, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF }; - - bool alu_busy[TOTAL_LATENCY + 1][ALU_COUNT]; - bool is_rotation[V4_INSTRUCTION_COUNT]; - bool rotated[4]; - int rotate_count = 0; - - memset(latency, 0, sizeof(latency)); - memset(asic_latency, 0, sizeof(asic_latency)); - memset(alu_busy, 0, sizeof(alu_busy)); - memset(is_rotation, 0, sizeof(is_rotation)); - memset(rotated, 0, sizeof(rotated)); - is_rotation[ROR] = true; - is_rotation[ROL] = true; - - int num_retries = 0; - code_size = 0; - - int total_iterations = 0; - r8_used = (VARIANT == xmrig::VARIANT_WOW); - - // Generate random code to achieve minimal required latency for our abstract CPU - // Try to get this latency for all 4 registers - while (((latency[0] < TOTAL_LATENCY) || (latency[1] < TOTAL_LATENCY) || (latency[2] < TOTAL_LATENCY) || (latency[3] < TOTAL_LATENCY)) && (num_retries < 64)) - { - // Fail-safe to guarantee loop termination - ++total_iterations; - if (total_iterations > 256) - break; - - check_data(&data_index, 1, data, sizeof(data)); - - const uint8_t c = ((uint8_t*)data)[data_index++]; - - // MUL = opcodes 0-2 - // ADD = opcode 3 - // SUB = opcode 4 - // ROR/ROL = opcode 5, shift direction is selected randomly - // XOR = opcodes 6-7 - uint8_t opcode = c & ((1 << V4_OPCODE_BITS) - 1); - if (opcode == 5) - { - check_data(&data_index, 1, data, sizeof(data)); - opcode = (data[data_index++] >= 0) ? ROR : ROL; - } - else if (opcode >= 6) - { - opcode = XOR; - } - else - { - opcode = (opcode <= 2) ? MUL : (opcode - 2); - } - - uint8_t dst_index = (c >> V4_OPCODE_BITS) & ((1 << V4_DST_INDEX_BITS) - 1); - uint8_t src_index = (c >> (V4_OPCODE_BITS + V4_DST_INDEX_BITS)) & ((1 << V4_SRC_INDEX_BITS) - 1); - - const int a = dst_index; - int b = src_index; - - // Don't do ADD/SUB/XOR with the same register - if (((opcode == ADD) || (opcode == SUB) || (opcode == XOR)) && (a == b)) - { - // a is always < 4, so we don't need to check bounds here - b = (VARIANT == xmrig::VARIANT_WOW) ? (a + 4) : 8; - src_index = b; - } - - // Don't do rotation with the same destination twice because it's equal to a single rotation - if (is_rotation[opcode] && rotated[a]) - { - continue; - } - - // Don't do the same instruction (except MUL) with the same source value twice because all other cases can be optimized: - // 2xADD(a, b, C) = ADD(a, b*2, C1+C2), same for SUB and rotations - // 2xXOR(a, b) = NOP - if ((opcode != MUL) && ((inst_data[a] & 0xFFFF00) == (opcode << 8) + ((inst_data[b] & 255) << 16))) - { - continue; - } - - // Find which ALU is available (and when) for this instruction - int next_latency = (latency[a] > latency[b]) ? latency[a] : latency[b]; - int alu_index = -1; - while (next_latency < TOTAL_LATENCY) - { - for (int i = op_ALUs[opcode] - 1; i >= 0; --i) - { - if (!alu_busy[next_latency][i]) - { - // ADD is implemented as two 1-cycle instructions on a real CPU, so do an additional availability check - if ((opcode == ADD) && alu_busy[next_latency + 1][i]) - { - continue; - } - - // Rotation can only start when previous rotation is finished, so do an additional availability check - if (is_rotation[opcode] && (next_latency < rotate_count * op_latency[opcode])) - { - continue; - } - - alu_index = i; - break; - } - } - if (alu_index >= 0) - { - break; - } - ++next_latency; - } - - // Don't generate instructions that leave some register unchanged for more than 7 cycles - if (next_latency > latency[a] + 7) - { - continue; - } - - next_latency += op_latency[opcode]; - - if (next_latency <= TOTAL_LATENCY) - { - if (is_rotation[opcode]) - { - ++rotate_count; - } - - // Mark ALU as busy only for the first cycle when it starts executing the instruction because ALUs are fully pipelined - alu_busy[next_latency - op_latency[opcode]][alu_index] = true; - latency[a] = next_latency; - - // ASIC is supposed to have enough ALUs to run as many independent instructions per cycle as possible, so latency calculation for ASIC is simple - asic_latency[a] = ((asic_latency[a] > asic_latency[b]) ? asic_latency[a] : asic_latency[b]) + asic_op_latency[opcode]; - - rotated[a] = is_rotation[opcode]; - - inst_data[a] = code_size + (opcode << 8) + ((inst_data[b] & 255) << 16); - - code[code_size].opcode = opcode; - code[code_size].dst_index = dst_index; - code[code_size].src_index = src_index; - code[code_size].C = 0; - - if (src_index == 8) - { - r8_used = true; - } - - if (opcode == ADD) - { - // ADD instruction is implemented as two 1-cycle instructions on a real CPU, so mark ALU as busy for the next cycle too - alu_busy[next_latency - op_latency[opcode] + 1][alu_index] = true; - - // ADD instruction requires 4 more random bytes for 32-bit constant "C" in "a = a + b + C" - check_data(&data_index, sizeof(uint32_t), data, sizeof(data)); - uint32_t t; - memcpy(&t, data + data_index, sizeof(uint32_t)); - code[code_size].C = SWAP32LE(t); - data_index += sizeof(uint32_t); - } - - ++code_size; - if (code_size >= NUM_INSTRUCTIONS_MIN) - { - break; - } - } - else - { - ++num_retries; - } - } - - // ASIC has more execution resources and can extract as much parallelism from the code as possible - // We need to add a few more MUL and ROR instructions to achieve minimal required latency for ASIC - // Get this latency for at least 1 of the 4 registers - const int prev_code_size = code_size; - while ((code_size < NUM_INSTRUCTIONS_MAX) && (asic_latency[0] < TOTAL_LATENCY) && (asic_latency[1] < TOTAL_LATENCY) && (asic_latency[2] < TOTAL_LATENCY) && (asic_latency[3] < TOTAL_LATENCY)) - { - int min_idx = 0; - int max_idx = 0; - for (int i = 1; i < 4; ++i) - { - if (asic_latency[i] < asic_latency[min_idx]) min_idx = i; - if (asic_latency[i] > asic_latency[max_idx]) max_idx = i; - } - - const uint8_t pattern[3] = { ROR, MUL, MUL }; - const uint8_t opcode = pattern[(code_size - prev_code_size) % 3]; - latency[min_idx] = latency[max_idx] + op_latency[opcode]; - asic_latency[min_idx] = asic_latency[max_idx] + asic_op_latency[opcode]; - - code[code_size].opcode = opcode; - code[code_size].dst_index = min_idx; - code[code_size].src_index = max_idx; - code[code_size].C = 0; - ++code_size; - } - - // There is ~98.15% chance that loop condition is false, so this loop will execute only 1 iteration most of the time - // It never does more than 4 iterations for all block heights < 10,000,000 - } while (!r8_used || (code_size < NUM_INSTRUCTIONS_MIN) || (code_size > NUM_INSTRUCTIONS_MAX)); - - // It's guaranteed that NUM_INSTRUCTIONS_MIN <= code_size <= NUM_INSTRUCTIONS_MAX here - // Add final instruction to stop the interpreter - code[code_size].opcode = RET; - code[code_size].dst_index = 0; - code[code_size].src_index = 0; - code[code_size].C = 0; - - return code_size; -} - -#endif diff --git a/src/Native/libcryptonight/xmrig/extra.cpp b/src/Native/libcryptonight/xmrig/extra.cpp deleted file mode 100644 index 50faeba457..0000000000 --- a/src/Native/libcryptonight/xmrig/extra.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include // for memcpy -#include "extra.h" -#include "crypto/CryptoNight_constants.h" -#include "common/cpu/Cpu.h" -#include "Mem.h" - -#if !defined(__ARM_ARCH) && !defined(XMRIG_NO_ASM) -template -static void patchCode(T dst, U src, const uint32_t iterations, const uint32_t mask) -{ - const uint8_t* p = reinterpret_cast(src); - - // Workaround for Visual Studio placing trampoline in debug builds. -# if defined(_MSC_VER) - if (p[0] == 0xE9) { - p += *(int32_t*)(p + 1) + 5; - } -# endif - - size_t size = 0; - while (*(uint32_t*)(p + size) != 0xDEADC0DE) { - ++size; - } - size += sizeof(uint32_t); - - memcpy((void*) dst, (const void*) src, size); - - uint8_t* patched_data = reinterpret_cast(dst); - for (size_t i = 0; i + sizeof(uint32_t) <= size; ++i) { - switch (*(uint32_t*)(patched_data + i)) { - case xmrig::CRYPTONIGHT_ITER: - *(uint32_t*)(patched_data + i) = iterations; - break; - - case xmrig::CRYPTONIGHT_MASK: - *(uint32_t*)(patched_data + i) = mask; - break; - } - } -} - - -extern "C" void cnv2_mainloop_ivybridge_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_mainloop_ryzen_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_mainloop_bulldozer_asm(cryptonight_ctx *ctx); -extern "C" void cnv2_double_mainloop_sandybridge_asm(cryptonight_ctx *ctx0, cryptonight_ctx *ctx1); - - -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ivybridge_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_ryzen_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_half_mainloop_bulldozer_asm = nullptr; -xmrig::CpuThread::cn_mainloop_double_fun cn_half_double_mainloop_sandybridge_asm = nullptr; - -xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ivybridge_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_ryzen_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_trtl_mainloop_bulldozer_asm = nullptr; -xmrig::CpuThread::cn_mainloop_double_fun cn_trtl_double_mainloop_sandybridge_asm = nullptr; - -xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_ivybridge_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_ryzen_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_zls_mainloop_bulldozer_asm = nullptr; -xmrig::CpuThread::cn_mainloop_double_fun cn_zls_double_mainloop_sandybridge_asm = nullptr; - -xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_ivybridge_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_ryzen_asm = nullptr; -xmrig::CpuThread::cn_mainloop_fun cn_double_mainloop_bulldozer_asm = nullptr; -xmrig::CpuThread::cn_mainloop_double_fun cn_double_double_mainloop_sandybridge_asm = nullptr; - -void xmrig::CpuThread::patchAsmVariants() -{ - const int allocation_size = 65536; - uint8_t *base = static_cast(Mem::allocateExecutableMemory(allocation_size)); - - cn_half_mainloop_ivybridge_asm = reinterpret_cast (base + 0x0000); - cn_half_mainloop_ryzen_asm = reinterpret_cast (base + 0x1000); - cn_half_mainloop_bulldozer_asm = reinterpret_cast (base + 0x2000); - cn_half_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0x3000); - - cn_trtl_mainloop_ivybridge_asm = reinterpret_cast (base + 0x4000); - cn_trtl_mainloop_ryzen_asm = reinterpret_cast (base + 0x5000); - cn_trtl_mainloop_bulldozer_asm = reinterpret_cast (base + 0x6000); - cn_trtl_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0x7000); - - cn_zls_mainloop_ivybridge_asm = reinterpret_cast (base + 0x8000); - cn_zls_mainloop_ryzen_asm = reinterpret_cast (base + 0x9000); - cn_zls_mainloop_bulldozer_asm = reinterpret_cast (base + 0xA000); - cn_zls_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0xB000); - - cn_double_mainloop_ivybridge_asm = reinterpret_cast (base + 0xC000); - cn_double_mainloop_ryzen_asm = reinterpret_cast (base + 0xD000); - cn_double_mainloop_bulldozer_asm = reinterpret_cast (base + 0xE000); - cn_double_double_mainloop_sandybridge_asm = reinterpret_cast (base + 0xF000); - - patchCode(cn_half_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_half_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_half_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_half_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_HALF_ITER, xmrig::CRYPTONIGHT_MASK); - - patchCode(cn_trtl_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); - patchCode(cn_trtl_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); - patchCode(cn_trtl_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); - patchCode(cn_trtl_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_TRTL_ITER, xmrig::CRYPTONIGHT_PICO_MASK); - - patchCode(cn_zls_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_ZLS_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_zls_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_ZLS_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_zls_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_ZLS_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_zls_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_ZLS_ITER, xmrig::CRYPTONIGHT_MASK); - - patchCode(cn_double_mainloop_ivybridge_asm, cnv2_mainloop_ivybridge_asm, xmrig::CRYPTONIGHT_DOUBLE_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_double_mainloop_ryzen_asm, cnv2_mainloop_ryzen_asm, xmrig::CRYPTONIGHT_DOUBLE_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_double_mainloop_bulldozer_asm, cnv2_mainloop_bulldozer_asm, xmrig::CRYPTONIGHT_DOUBLE_ITER, xmrig::CRYPTONIGHT_MASK); - patchCode(cn_double_double_mainloop_sandybridge_asm, cnv2_double_mainloop_sandybridge_asm, xmrig::CRYPTONIGHT_DOUBLE_ITER, xmrig::CRYPTONIGHT_MASK); - - Mem::protectExecutableMemory(base, allocation_size); - Mem::flushInstructionCache(base, allocation_size); -} - -struct Static { - Static() { - xmrig::Cpu::init(); - xmrig::CpuThread::patchAsmVariants(); - } -} s; - -#endif diff --git a/src/Native/libcryptonight/xmrig/extra.h b/src/Native/libcryptonight/xmrig/extra.h deleted file mode 100644 index f90b0fef45..0000000000 --- a/src/Native/libcryptonight/xmrig/extra.h +++ /dev/null @@ -1,41 +0,0 @@ -/* XMRig - * Copyright 2010 Jeff Garzik - * Copyright 2012-2014 pooler - * Copyright 2014 Lucas Jones - * Copyright 2014-2016 Wolf9466 - * Copyright 2016 Jay D Dee - * Copyright 2017-2018 XMR-Stak , - * Copyright 2018-2019 SChernykh - * Copyright 2016-2019 XMRig , - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -#include "crypto/CryptoNight.h" - -namespace xmrig { - -class CpuThread { - public: - typedef void (*cn_mainloop_fun)(cryptonight_ctx *ctx); - typedef void (*cn_mainloop_double_fun)(cryptonight_ctx *ctx1, cryptonight_ctx *ctx2); - -# ifndef XMRIG_NO_ASM - static void patchAsmVariants(); -# endif -}; - -} diff --git a/src/Native/libcryptonote/Makefile b/src/Native/libcryptonote/Makefile index 2b1b84aada..71f5e1d78a 100644 --- a/src/Native/libcryptonote/Makefile +++ b/src/Native/libcryptonote/Makefile @@ -7,12 +7,12 @@ LDLIBS = -lboost_system -lboost_date_time TARGET = libcryptonote.so OBJECTS = contrib/epee/src/hex.o \ - common/base58.o crypto/aesb.o crypto/blake256.o crypto/chacha.o \ - contrib/epee/src/memwipe.o \ - crypto/crypto-ops-data.o crypto/crypto-ops.o crypto/crypto.o crypto/groestl.o crypto/hash-extra-blake.o \ - crypto/hash-extra-groestl.o crypto/hash-extra-jh.o crypto/hash-extra-skein.o crypto/hash.o crypto/jh.o \ - crypto/keccak.o crypto/oaes_lib.o crypto/random.o crypto/skein.o crypto/tree-hash.o \ - crypto/slow-hash-lite.o cryptonote_basic/cryptonote_format_utils.o exports.o + common/base58.o crypto/aesb.o crypto/blake256.o crypto/chacha.o \ + contrib/epee/src/memwipe.o \ + crypto/crypto-ops-data.o crypto/crypto-ops.o crypto/crypto.o crypto/groestl.o crypto/hash-extra-blake.o \ + crypto/hash-extra-groestl.o crypto/hash-extra-jh.o crypto/hash-extra-skein.o crypto/hash.o crypto/jh.o \ + crypto/keccak.o crypto/oaes_lib.o crypto/random.o crypto/skein.o crypto/tree-hash.o \ + crypto/slow-hash-lite.o cryptonote_basic/cryptonote_format_utils.o exports.o all: $(TARGET) diff --git a/src/Native/libmultihash/Makefile b/src/Native/libmultihash/Makefile index 0c1a2e2683..feb4758489 100644 --- a/src/Native/libmultihash/Makefile +++ b/src/Native/libmultihash/Makefile @@ -12,7 +12,7 @@ OBJECTS = bcrypt.o blake.o blake2s.o c11.o dcrypt.o fresh.o lane.o \ sha3/sph_luffa.o sha3/sph_shabal.o sha3/sph_shavite.o sha3/sph_simd.o sha3/sph_skein.o sha3/sph_whirlpool.o \ sha3/sph_haval.o sha3/sph_sha2.o sha3/sph_sha2big.o sha3/sph_blake2s.o sha3/sm3.o sha3/panama.o \ sha3/extra.o sha3/gost_streebog.o sha3/sph_tiger.o sha3/SWIFFTX.o KeccakP-800-reference.o \ - shavite3.o skein.o x11.o x13.o x15.o x17.o x16r.o x16s.o x21s.o odocrypt.o x25x.o \ + shavite3.o skein.o x11.o x13.o x15.o x17.o x16r.o x16s.o x21s.o x22i.o odocrypt.o x25x.o \ Lyra2.o Lyra2RE.o Sponge.o geek.o \ equi/util.o equi/support/cleanse.o equi/random.o \ equi/uint256.o equi/arith_uint256.o equi/crypto/hmac_sha512.o \ diff --git a/src/Native/libmultihash/exports.cpp b/src/Native/libmultihash/exports.cpp index 02194b73fc..bfd8bf6d37 100644 --- a/src/Native/libmultihash/exports.cpp +++ b/src/Native/libmultihash/exports.cpp @@ -37,6 +37,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "nist5.h" #include "x15.h" #include "x17.h" +#include "x22i.h" #include "fresh.h" #include "dcrypt.h" #include "jh.h" @@ -223,6 +224,11 @@ extern "C" MODULE_API void x21s_export(const char* input, char* output, uint32_t x21s_hash(input, output, input_len); } +extern "C" MODULE_API void x22i_export(const char* input, char* output, uint32_t input_len) +{ + x22i_hash(input, output, input_len); +} + extern "C" MODULE_API void x25x_export(const char* input, char* output, uint32_t input_len) { x25x_hash(input, output, input_len); diff --git a/src/Native/libmultihash/libmultihash.vcxproj b/src/Native/libmultihash/libmultihash.vcxproj index 7522da19d9..6786ef2f7a 100644 --- a/src/Native/libmultihash/libmultihash.vcxproj +++ b/src/Native/libmultihash/libmultihash.vcxproj @@ -264,6 +264,7 @@ + @@ -351,6 +352,9 @@ + + MaxSpeed + diff --git a/src/Native/libmultihash/libmultihash.vcxproj.filters b/src/Native/libmultihash/libmultihash.vcxproj.filters index 0ec24faa28..caa0f4a75c 100644 --- a/src/Native/libmultihash/libmultihash.vcxproj.filters +++ b/src/Native/libmultihash/libmultihash.vcxproj.filters @@ -302,6 +302,9 @@ Header Files + + Header Files + @@ -559,6 +562,9 @@ Source Files + + Source Files + diff --git a/src/Native/libmultihash/x22i.c b/src/Native/libmultihash/x22i.c new file mode 100644 index 0000000000..2533f464b8 --- /dev/null +++ b/src/Native/libmultihash/x22i.c @@ -0,0 +1,149 @@ +#include +#include +#include + +#include "sha3/extra.h" +#include "sha3/sph_blake.h" +#include "sha3/sph_bmw.h" +#include "sha3/sph_groestl.h" +#include "sha3/sph_jh.h" +#include "sha3/sph_keccak.h" +#include "sha3/sph_skein.h" +#include "sha3/sph_luffa.h" +#include "sha3/sph_cubehash.h" +#include "sha3/sph_shavite.h" +#include "sha3/sph_simd.h" +#include "sha3/sph_echo.h" +#include "sha3/sph_hamsi.h" +#include "sha3/sph_fugue.h" +#include "sha3/sph_shabal.h" +#include "sha3/sph_whirlpool.h" +#include "sha3/sph_sha2.h" +#include "sha3/sph_haval.h" +#include "sha3/sph_tiger.h" +#include "Lyra2.h" +#include "sha3/gost_streebog.h" +#include "sha3/SWIFFTX.h" + +// barrystyle 05112018 +typedef struct +{ + unsigned char hash[64]; +} uint512; + +void x22i_hash(const char* input, char* output, size_t len) +{ + sph_blake512_context ctx_blake; + sph_bmw512_context ctx_bmw; + sph_groestl512_context ctx_groestl; + sph_jh512_context ctx_jh; + sph_keccak512_context ctx_keccak; + sph_skein512_context ctx_skein; + sph_luffa512_context ctx_luffa; + sph_cubehash512_context ctx_cubehash; + sph_shavite512_context ctx_shavite; + sph_simd512_context ctx_simd; + sph_echo512_context ctx_echo; + sph_hamsi512_context ctx_hamsi; + sph_fugue512_context ctx_fugue; + sph_shabal512_context ctx_shabal; + sph_whirlpool_context ctx_whirlpool; + sph_sha512_context ctx_sha2; + sph_haval256_5_context ctx_haval; + sph_tiger_context ctx_tiger; + sph_gost512_context ctx_gost; + sph_sha256_context ctx_sha; + static unsigned char pblank[1]; + uint512 hash[22]; + + memset(&hash, 0, sizeof(hash)); + + sph_blake512_init(&ctx_blake); + sph_blake512(&ctx_blake, input, len); + sph_blake512_close(&ctx_blake, (void *) &hash[0]); + + sph_bmw512_init(&ctx_bmw); + sph_bmw512(&ctx_bmw, (const void *) &hash[0], 64); + sph_bmw512_close(&ctx_bmw, (void *) &hash[1]); + + sph_groestl512_init(&ctx_groestl); + sph_groestl512(&ctx_groestl, (const void *) &hash[1], 64); + sph_groestl512_close(&ctx_groestl, (void *) &hash[2]); + + sph_skein512_init(&ctx_skein); + sph_skein512(&ctx_skein, (const void *) &hash[2], 64); + sph_skein512_close(&ctx_skein, (void *) &hash[3]); + + sph_jh512_init(&ctx_jh); + sph_jh512(&ctx_jh, (const void *) &hash[3], 64); + sph_jh512_close(&ctx_jh, (void *) &hash[4]); + + sph_keccak512_init(&ctx_keccak); + sph_keccak512(&ctx_keccak, (const void *) &hash[4], 64); + sph_keccak512_close(&ctx_keccak, (void *) &hash[5]); + + sph_luffa512_init(&ctx_luffa); + sph_luffa512(&ctx_luffa, (void *) &hash[5], 64); + sph_luffa512_close(&ctx_luffa, (void *) &hash[6]); + + sph_cubehash512_init(&ctx_cubehash); + sph_cubehash512(&ctx_cubehash, (const void *) &hash[6], 64); + sph_cubehash512_close(&ctx_cubehash, (void *) &hash[7]); + + sph_shavite512_init(&ctx_shavite); + sph_shavite512(&ctx_shavite, (const void *) &hash[7], 64); + sph_shavite512_close(&ctx_shavite, (void *) &hash[8]); + + sph_simd512_init(&ctx_simd); + sph_simd512(&ctx_simd, (const void *) &hash[8], 64); + sph_simd512_close(&ctx_simd, (void *) &hash[9]); + + sph_echo512_init(&ctx_echo); + sph_echo512(&ctx_echo, (const void *) &hash[9], 64); + sph_echo512_close(&ctx_echo, (void *) &hash[10]); + + sph_hamsi512_init(&ctx_hamsi); + sph_hamsi512(&ctx_hamsi, (const void *) &hash[10], 64); + sph_hamsi512_close(&ctx_hamsi, (void *) &hash[11]); + + sph_fugue512_init(&ctx_fugue); + sph_fugue512(&ctx_fugue, (const void *) &hash[11], 64); + sph_fugue512_close(&ctx_fugue, (void *) &hash[12]); + + sph_shabal512_init(&ctx_shabal); + sph_shabal512(&ctx_shabal, (const void *) &hash[12], 64); + sph_shabal512_close(&ctx_shabal, (void *) &hash[13]); + + sph_whirlpool_init(&ctx_whirlpool); + sph_whirlpool(&ctx_whirlpool, (const void *) &hash[13], 64); + sph_whirlpool_close(&ctx_whirlpool, (void *) &hash[14]); + + sph_sha512_init(&ctx_sha2); + sph_sha512(&ctx_sha2, (const void *) &hash[14], 64); + sph_sha512_close(&ctx_sha2, (void *) &hash[15]); + + unsigned char temp[SWIFFTX_OUTPUT_BLOCK_SIZE] = { 0 }; + InitializeSWIFFTX(); + ComputeSingleSWIFFTX((unsigned char*)& hash[12], temp, false); + + memcpy((unsigned char*)& hash[16], temp, 64); + sph_haval256_5_init(&ctx_haval); + sph_haval256_5(&ctx_haval, (const void *) &hash[16], 64); + sph_haval256_5_close(&ctx_haval, (void *) &hash[17]); + + sph_tiger_init(&ctx_tiger); + sph_tiger(&ctx_tiger, (const void *) &hash[17], 64); + sph_tiger_close(&ctx_tiger, (void *) &hash[18]); + + LYRA2((void *) &hash[19], 32, (const void *) &hash[18], 32, (const void *) &hash[18], 32, 1, 4, 4); + + sph_gost512_init(&ctx_gost); + sph_gost512(&ctx_gost, (const void *) &hash[19], 64); + sph_gost512_close(&ctx_gost, (void *) &hash[20]); + + sph_sha256_init(&ctx_sha); + sph_sha256(&ctx_sha, (const void *) &hash[20], 64); + sph_sha256_close(&ctx_sha, (void *) &hash[21]); + + memcpy(output, &hash[21], 32); +} diff --git a/src/Native/libmultihash/x22i.h b/src/Native/libmultihash/x22i.h new file mode 100644 index 0000000000..6daaab143d --- /dev/null +++ b/src/Native/libmultihash/x22i.h @@ -0,0 +1,16 @@ +#ifndef X22I_H +#define X22I_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void x22i_hash(const char* input, char* output, size_t input_len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/Native/librandomx/Makefile b/src/Native/librandomx/Makefile new file mode 100644 index 0000000000..e2f0764dd0 --- /dev/null +++ b/src/Native/librandomx/Makefile @@ -0,0 +1,17 @@ +# Create shared library librandomx.so from static library librandomx.a using --whole-archive + +CC = g++ +LDFLAGS = -shared -pthread -L. -Wl,-whole-archive librandomx.a -Wl,-no-whole-archive +LDLIBS = -lstdc++ -lgcc -lc +TARGET = librandomx.so + +all: $(TARGET) + +$(TARGET): $(OBJECTS) + $(CC) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +.PHONY: clean + +clean: + find . -name '*.o' -exec rm -r {} \; + rm -f librandomx.so