Target generation, ideally, to those files we'll need for doing crypto.
This commit is contained in:
@@ -11,13 +11,14 @@ import Control.Monad(replicateM, void)
|
|||||||
import Conversions(conversions, signedConversions)
|
import Conversions(conversions, signedConversions)
|
||||||
import CryptoNum(cryptoNum)
|
import CryptoNum(cryptoNum)
|
||||||
import Control.Monad(forM_,unless)
|
import Control.Monad(forM_,unless)
|
||||||
|
import Data.List(nub)
|
||||||
import Data.Text.Lazy(Text, pack)
|
import Data.Text.Lazy(Text, pack)
|
||||||
import Division(divisionOps)
|
import Division(divisionOps)
|
||||||
import GHC.Conc(getNumCapabilities)
|
import GHC.Conc(getNumCapabilities)
|
||||||
import ModInv(generateModInvOps)
|
import ModInv(generateModInvOps)
|
||||||
import ModOps(modulusOps)
|
import ModOps(modulusOps)
|
||||||
import Multiply(safeMultiplyOps, unsafeMultiplyOps)
|
import Multiply(safeMultiplyOps, unsafeMultiplyOps)
|
||||||
import RustModule(RustModule,Task(..),generateTasks)
|
import RustModule(RustModule(suggested),Task(..),generateTasks)
|
||||||
import Scale(safeScaleOps, unsafeScaleOps)
|
import Scale(safeScaleOps, unsafeScaleOps)
|
||||||
import Shift(shiftOps, signedShiftOps)
|
import Shift(shiftOps, signedShiftOps)
|
||||||
import Signed(signedBaseOps)
|
import Signed(signedBaseOps)
|
||||||
@@ -30,14 +31,19 @@ import System.IO(IOMode(..),withFile)
|
|||||||
import System.ProgressBar(Label(..), Progress(..), ProgressBar, Timing, defStyle, newProgressBar, stylePrefix, updateProgress)
|
import System.ProgressBar(Label(..), Progress(..), ProgressBar, Timing, defStyle, newProgressBar, stylePrefix, updateProgress)
|
||||||
import System.Random(getStdGen)
|
import System.Random(getStdGen)
|
||||||
|
|
||||||
lowestBitsize :: Word
|
rsaWordSizes :: [Word]
|
||||||
lowestBitsize = 192
|
rsaWordSizes = [512, 1024, 2048, 3072, 4096, 8192, 15360]
|
||||||
|
|
||||||
highestBitsize :: Word
|
dsaWordSizes :: [Word]
|
||||||
highestBitsize = 512
|
dsaWordSizes = [192, 256, 384, 1024, 2048, 3072]
|
||||||
|
|
||||||
|
ecdsaIntSizes :: [Word]
|
||||||
|
ecdsaIntSizes = [192, 256, 384, 576]
|
||||||
|
|
||||||
bitsizes :: [Word]
|
bitsizes :: [Word]
|
||||||
bitsizes = [lowestBitsize,lowestBitsize+64..highestBitsize]
|
bitsizes = expandSizes initialSet
|
||||||
|
where
|
||||||
|
initialSet = nub (rsaWordSizes ++ dsaWordSizes ++ ecdsaIntSizes)
|
||||||
|
|
||||||
unsignedFiles :: [RustModule]
|
unsignedFiles :: [RustModule]
|
||||||
unsignedFiles = [
|
unsignedFiles = [
|
||||||
@@ -75,6 +81,11 @@ signedFiles = [
|
|||||||
allFiles :: [RustModule]
|
allFiles :: [RustModule]
|
||||||
allFiles = unsignedFiles ++ signedFiles
|
allFiles = unsignedFiles ++ signedFiles
|
||||||
|
|
||||||
|
expandSizes :: [Word] -> [Word]
|
||||||
|
expandSizes ls = bigger
|
||||||
|
where
|
||||||
|
bigger = nub (ls ++ concatMap (\ f -> concatMap (\ x -> suggested f x) ls) allFiles)
|
||||||
|
|
||||||
printLast :: Progress String -> Timing -> Text
|
printLast :: Progress String -> Timing -> Text
|
||||||
printLast prog _ = pack (progressCustom prog)
|
printLast prog _ = pack (progressCustom prog)
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ modexpLR bitsize b e m = go (bitsize - 1) 1
|
|||||||
where
|
where
|
||||||
go bit r0
|
go bit r0
|
||||||
| bit < 0 = r0
|
| bit < 0 = r0
|
||||||
| testBit e bit = trace ("1: r = " ++ showHex r2 "") $ go (bit - 1) r2
|
| testBit e bit = go (bit - 1) r2
|
||||||
| otherwise = trace ("0: r = " ++ showHex r1 "") $ go (bit - 1) r1
|
| otherwise = go (bit - 1) r1
|
||||||
where
|
where
|
||||||
r1 = (r0 * r0) `mod` m
|
r1 = (r0 * r0) `mod` m
|
||||||
r2 = (r1 * b) `mod` m
|
r2 = (r1 * b) `mod` m
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ library
|
|||||||
Conversions,
|
Conversions,
|
||||||
CryptoNum,
|
CryptoNum,
|
||||||
Division,
|
Division,
|
||||||
Gen,
|
|
||||||
Generators,
|
Generators,
|
||||||
Karatsuba,
|
Karatsuba,
|
||||||
ModInv,
|
ModInv,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ module Add(
|
|||||||
import Data.Bits((.&.))
|
import Data.Bits((.&.))
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -22,6 +21,7 @@ import System.Random(RandomGen)
|
|||||||
safeAddOps :: RustModule
|
safeAddOps :: RustModule
|
||||||
safeAddOps = RustModule {
|
safeAddOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "safe_add",
|
outputName = "safe_add",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareSafeAddOperators,
|
generator = declareSafeAddOperators,
|
||||||
@@ -31,6 +31,7 @@ safeAddOps = RustModule {
|
|||||||
unsafeAddOps :: RustModule
|
unsafeAddOps :: RustModule
|
||||||
unsafeAddOps = RustModule {
|
unsafeAddOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_add",
|
outputName = "unsafe_add",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareUnsafeAddOperators,
|
generator = declareUnsafeAddOperators,
|
||||||
@@ -40,6 +41,7 @@ unsafeAddOps = RustModule {
|
|||||||
safeSignedAddOps :: RustModule
|
safeSignedAddOps :: RustModule
|
||||||
safeSignedAddOps = RustModule {
|
safeSignedAddOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "safe_sadd",
|
outputName = "safe_sadd",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSafeSignedAddOperators,
|
generator = declareSafeSignedAddOperators,
|
||||||
@@ -49,6 +51,7 @@ safeSignedAddOps = RustModule {
|
|||||||
unsafeSignedAddOps :: RustModule
|
unsafeSignedAddOps :: RustModule
|
||||||
unsafeSignedAddOps = RustModule {
|
unsafeSignedAddOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_sadd",
|
outputName = "unsafe_sadd",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareUnsafeSignedAddOperators,
|
generator = declareUnsafeSignedAddOperators,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import RustModule
|
|||||||
base :: RustModule
|
base :: RustModule
|
||||||
base = RustModule {
|
base = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "base",
|
outputName = "base",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareBaseStructure,
|
generator = declareBaseStructure,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ module BinaryOps(
|
|||||||
import Data.Bits(xor,(.&.),(.|.))
|
import Data.Bits(xor,(.&.),(.|.))
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -19,6 +18,7 @@ import System.Random(RandomGen)
|
|||||||
binaryOps :: RustModule
|
binaryOps :: RustModule
|
||||||
binaryOps = RustModule {
|
binaryOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "binary",
|
outputName = "binary",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareBinaryOperators,
|
generator = declareBinaryOperators,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import System.Random(RandomGen)
|
|||||||
comparisons :: RustModule
|
comparisons :: RustModule
|
||||||
comparisons = RustModule {
|
comparisons = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "compare",
|
outputName = "compare",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareComparators,
|
generator = declareComparators,
|
||||||
@@ -24,6 +25,7 @@ comparisons = RustModule {
|
|||||||
signedComparisons :: RustModule
|
signedComparisons :: RustModule
|
||||||
signedComparisons = RustModule {
|
signedComparisons = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "scompare",
|
outputName = "scompare",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSignedComparators,
|
generator = declareSignedComparators,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ module Conversions(
|
|||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
import Gen(toLit)
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
import Language.Rust.Quote
|
import Language.Rust.Quote
|
||||||
@@ -15,6 +15,7 @@ import RustModule
|
|||||||
conversions :: RustModule
|
conversions :: RustModule
|
||||||
conversions = RustModule {
|
conversions = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "conversions",
|
outputName = "conversions",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareConversions,
|
generator = declareConversions,
|
||||||
@@ -24,6 +25,7 @@ conversions = RustModule {
|
|||||||
signedConversions :: RustModule
|
signedConversions :: RustModule
|
||||||
signedConversions = RustModule {
|
signedConversions = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "sconversions",
|
outputName = "sconversions",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSignedConversions,
|
generator = declareSignedConversions,
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ module CryptoNum(
|
|||||||
import Data.Bits(testBit)
|
import Data.Bits(testBit)
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -19,6 +18,7 @@ import System.Random(RandomGen)
|
|||||||
cryptoNum :: RustModule
|
cryptoNum :: RustModule
|
||||||
cryptoNum = RustModule {
|
cryptoNum = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "cryptonum",
|
outputName = "cryptonum",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareCryptoNumInstance,
|
generator = declareCryptoNumInstance,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ module Division(divisionOps)
|
|||||||
|
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -16,6 +15,7 @@ import System.Random(RandomGen)
|
|||||||
divisionOps :: RustModule
|
divisionOps :: RustModule
|
||||||
divisionOps = RustModule {
|
divisionOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "divmod",
|
outputName = "divmod",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareDivision,
|
generator = declareDivision,
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
|
||||||
module Gen(
|
|
||||||
toLit
|
|
||||||
)
|
|
||||||
where
|
|
||||||
|
|
||||||
import Language.Rust.Data.Position
|
|
||||||
import Language.Rust.Syntax
|
|
||||||
|
|
||||||
toLit :: Word -> Expr Span
|
|
||||||
toLit i = Lit [] (Int Dec (fromIntegral i) Unsuffixed mempty) mempty
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
module Generators
|
module Generators
|
||||||
where
|
where
|
||||||
|
|
||||||
|
import Language.Rust.Data.Position
|
||||||
|
import Language.Rust.Syntax
|
||||||
import Numeric(showHex)
|
import Numeric(showHex)
|
||||||
import System.Random(RandomGen,random,randomR)
|
import System.Random(RandomGen,random,randomR)
|
||||||
|
|
||||||
|
toLit :: Word -> Expr Span
|
||||||
|
toLit i = Lit [] (Int Dec (fromIntegral i) Unsuffixed mempty) mempty
|
||||||
|
|
||||||
generateNum :: RandomGen g => g -> Word -> (Integer, g)
|
generateNum :: RandomGen g => g -> Word -> (Integer, g)
|
||||||
generateNum g size =
|
generateNum g size =
|
||||||
let (x, g') = random g
|
let (x, g') = random g
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import System.Random(RandomGen)
|
|||||||
generateModInvOps :: RustModule
|
generateModInvOps :: RustModule
|
||||||
generateModInvOps = RustModule {
|
generateModInvOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "modinv",
|
outputName = "modinv",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareModInv,
|
generator = declareModInv,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import System.Random(RandomGen)
|
|||||||
modulusOps :: RustModule
|
modulusOps :: RustModule
|
||||||
modulusOps = RustModule {
|
modulusOps = RustModule {
|
||||||
predicate = \ me others -> (me * 2) `elem` others,
|
predicate = \ me others -> (me * 2) `elem` others,
|
||||||
|
suggested = \ me -> [me * 2],
|
||||||
outputName = "modops",
|
outputName = "modops",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareModOps,
|
generator = declareModOps,
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
{-# LANGUAGE QuasiQuotes #-}
|
{-# LANGUAGE QuasiQuotes #-}
|
||||||
module Multiply
|
module Multiply(
|
||||||
-- (
|
safeMultiplyOps
|
||||||
-- safeMultiplyOps
|
, unsafeMultiplyOps
|
||||||
-- , unsafeMultiplyOps
|
)
|
||||||
-- )
|
|
||||||
where
|
where
|
||||||
|
|
||||||
import Data.Bits((.&.))
|
import Data.Bits((.&.))
|
||||||
@@ -11,7 +10,6 @@ import Data.List(foldl')
|
|||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Karatsuba
|
import Karatsuba
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
@@ -24,19 +22,21 @@ import System.Random(RandomGen)
|
|||||||
safeMultiplyOps :: RustModule
|
safeMultiplyOps :: RustModule
|
||||||
safeMultiplyOps = RustModule {
|
safeMultiplyOps = RustModule {
|
||||||
predicate = \ me others -> (me * 2) `elem` others,
|
predicate = \ me others -> (me * 2) `elem` others,
|
||||||
|
suggested = \ me -> [me * 2],
|
||||||
outputName = "safe_mul",
|
outputName = "safe_mul",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareSafeMulOperators,
|
generator = declareSafeMulOperators,
|
||||||
testCase = Nothing -- Just generateSafeTest
|
testCase = Just generateSafeTest
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafeMultiplyOps :: RustModule
|
unsafeMultiplyOps :: RustModule
|
||||||
unsafeMultiplyOps = RustModule {
|
unsafeMultiplyOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_mul",
|
outputName = "unsafe_mul",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareUnsafeMulOperators,
|
generator = declareUnsafeMulOperators,
|
||||||
testCase = Nothing -- Just generateUnsafeTest
|
testCase = Just generateUnsafeTest
|
||||||
}
|
}
|
||||||
|
|
||||||
declareSafeMulOperators :: Word -> [Word] -> SourceFile Span
|
declareSafeMulOperators :: Word -> [Word] -> SourceFile Span
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ targetTestGenerationPicos =
|
|||||||
|
|
||||||
data RustModule = RustModule {
|
data RustModule = RustModule {
|
||||||
predicate :: Word -> [Word] -> Bool,
|
predicate :: Word -> [Word] -> Bool,
|
||||||
|
suggested :: Word -> [Word],
|
||||||
outputName :: String,
|
outputName :: String,
|
||||||
isUnsigned :: Bool,
|
isUnsigned :: Bool,
|
||||||
generator :: Word -> [Word] -> SourceFile Span,
|
generator :: Word -> [Word] -> SourceFile Span,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ module Scale(
|
|||||||
import Data.Bits((.&.))
|
import Data.Bits((.&.))
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -20,6 +19,7 @@ import System.Random(RandomGen)
|
|||||||
safeScaleOps :: RustModule
|
safeScaleOps :: RustModule
|
||||||
safeScaleOps = RustModule {
|
safeScaleOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "safe_scale",
|
outputName = "safe_scale",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareSafeScaleOperators,
|
generator = declareSafeScaleOperators,
|
||||||
@@ -29,6 +29,7 @@ safeScaleOps = RustModule {
|
|||||||
unsafeScaleOps :: RustModule
|
unsafeScaleOps :: RustModule
|
||||||
unsafeScaleOps = RustModule {
|
unsafeScaleOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_scale",
|
outputName = "unsafe_scale",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareUnsafeScaleOperators,
|
generator = declareUnsafeScaleOperators,
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ module Shift(shiftOps, signedShiftOps)
|
|||||||
import Data.Bits(shiftL,shiftR)
|
import Data.Bits(shiftL,shiftR)
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -17,6 +16,7 @@ import System.Random(RandomGen)
|
|||||||
shiftOps :: RustModule
|
shiftOps :: RustModule
|
||||||
shiftOps = RustModule {
|
shiftOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "shift",
|
outputName = "shift",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareShiftOperators,
|
generator = declareShiftOperators,
|
||||||
@@ -26,6 +26,7 @@ shiftOps = RustModule {
|
|||||||
signedShiftOps :: RustModule
|
signedShiftOps :: RustModule
|
||||||
signedShiftOps = RustModule {
|
signedShiftOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "sshift",
|
outputName = "sshift",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSignedShiftOperators,
|
generator = declareSignedShiftOperators,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import RustModule
|
|||||||
signedBaseOps :: RustModule
|
signedBaseOps :: RustModule
|
||||||
signedBaseOps = RustModule {
|
signedBaseOps = RustModule {
|
||||||
predicate = const (const True),
|
predicate = const (const True),
|
||||||
|
suggested = const [],
|
||||||
outputName = "base",
|
outputName = "base",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSigned,
|
generator = declareSigned,
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ module Subtract(
|
|||||||
import Data.Bits((.&.))
|
import Data.Bits((.&.))
|
||||||
import Data.Map.Strict(Map)
|
import Data.Map.Strict(Map)
|
||||||
import qualified Data.Map.Strict as Map
|
import qualified Data.Map.Strict as Map
|
||||||
import Gen(toLit)
|
|
||||||
import Generators
|
import Generators
|
||||||
import Language.Rust.Data.Ident
|
import Language.Rust.Data.Ident
|
||||||
import Language.Rust.Data.Position
|
import Language.Rust.Data.Position
|
||||||
@@ -22,6 +21,7 @@ import System.Random(RandomGen)
|
|||||||
safeSubtractOps :: RustModule
|
safeSubtractOps :: RustModule
|
||||||
safeSubtractOps = RustModule {
|
safeSubtractOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "safe_sub",
|
outputName = "safe_sub",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareSafeSubtractOperators,
|
generator = declareSafeSubtractOperators,
|
||||||
@@ -31,6 +31,7 @@ safeSubtractOps = RustModule {
|
|||||||
safeSignedSubtractOps :: RustModule
|
safeSignedSubtractOps :: RustModule
|
||||||
safeSignedSubtractOps = RustModule {
|
safeSignedSubtractOps = RustModule {
|
||||||
predicate = \ me others -> (me + 64) `elem` others,
|
predicate = \ me others -> (me + 64) `elem` others,
|
||||||
|
suggested = \ me -> [me + 64],
|
||||||
outputName = "safe_ssub",
|
outputName = "safe_ssub",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareSafeSignedSubtractOperators,
|
generator = declareSafeSignedSubtractOperators,
|
||||||
@@ -40,6 +41,7 @@ safeSignedSubtractOps = RustModule {
|
|||||||
unsafeSubtractOps :: RustModule
|
unsafeSubtractOps :: RustModule
|
||||||
unsafeSubtractOps = RustModule {
|
unsafeSubtractOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_sub",
|
outputName = "unsafe_sub",
|
||||||
isUnsigned = True,
|
isUnsigned = True,
|
||||||
generator = declareUnsafeSubtractOperators,
|
generator = declareUnsafeSubtractOperators,
|
||||||
@@ -49,6 +51,7 @@ unsafeSubtractOps = RustModule {
|
|||||||
unsafeSignedSubtractOps :: RustModule
|
unsafeSignedSubtractOps :: RustModule
|
||||||
unsafeSignedSubtractOps = RustModule {
|
unsafeSignedSubtractOps = RustModule {
|
||||||
predicate = \ _ _ -> True,
|
predicate = \ _ _ -> True,
|
||||||
|
suggested = const [],
|
||||||
outputName = "unsafe_ssub",
|
outputName = "unsafe_ssub",
|
||||||
isUnsigned = False,
|
isUnsigned = False,
|
||||||
generator = declareUnsafeSignedSubtractOperators,
|
generator = declareUnsafeSignedSubtractOperators,
|
||||||
|
|||||||
Reference in New Issue
Block a user