<commit_before>{-# OPTIONS_GHC -cpp -fbang-patterns #-}
module C.Arch(determineArch,primitiveInfo,genericPrimitiveInfo,isFGrin) where



{-
    architecture specification consists of a string of form

    backend-cpu-flags

    where any of the fields may be omitted.

    valid backends are currently "ghc" and "grin", valid cpus are listed in arch/ and 'generic', and flags consist of 32 and 64
    for instance

    grin-i686

    there are only 2 ghc versions of the backend, ghc-32 and ghc-64.

-}

import Char
import Data.List
import System.IO.Unsafe
import System.Info
import qualified Data.Map as Map

import C.Prims
import Options
import Util.Gen
import qualified FlagOpts as FO

#include "../arch/generic.arch"
#include "../arch/i686.arch"
#include "../arch/x86_64.arch"

#include "MachDeps.h"

cpu_alias s = maybe arch_error id $ lookup s' $ [
    ("unknown","generic"),
    ("amd64","x86_64"),
    ("i386","i686"),
    ("i486","i686"),
    ("i586","i686")
    ] ++ [ (n,n) | n <- archs ] where s' = map toLower s

archs = ["generic","i686","x86_64"]

arch_map = [
    ("generic",Nothing,arch_generic,[]),
    ("i686",Nothing,arch_i686,[]),
    ("x86_64",Just 64,arch_x86_64,[]),
    ("x86_64",Just 32,arch_i686,["-m32"])
    ]

available_archs = snub $ "ghc":"ghc-64":"ghc-32":[ n | (n,_,_,_) <- arch_map ]  ++ [ n ++ "-" ++ show b |  (n,Just b,_,_) <- arch_map]

primitiveInfo :: Monad m => ExtType -> m PrimType
primitiveInfo et = Map.lookup et primMap

genericPrimitiveInfo :: Monad m => ExtType -> m PrimType
genericPrimitiveInfo et = Map.lookup et primMap


primMap :: Map.Map ExtType PrimType
primMap = Map.fromList [ (primTypeName a,a) | a <- as ] where
    (_,_,as,_) = unsafePerformIO determineArch

isFGrin :: Bool
isFGrin = case optArch options of
    Nothing -> False
    Just o -> "fgrin" `isPrefixOf` o<commit_msg>make -mfgrin the default<commit_after>{-# OPTIONS_GHC -cpp -fbang-patterns #-}
module C.Arch(determineArch,primitiveInfo,genericPrimitiveInfo,isFGrin) where



{-
    architecture specification consists of a string of form

    backend-cpu-flags

    where any of the fields may be omitted.

    valid backends are currently "ghc" and "grin", valid cpus are listed in arch/ and 'generic', and flags consist of 32 and 64
    for instance

    grin-i686

    there are only 2 ghc versions of the backend, ghc-32 and ghc-64.

-}

import Char
import Data.List
import System.IO.Unsafe
import System.Info
import qualified Data.Map as Map

import C.Prims
import Options
import Util.Gen
import qualified FlagOpts as FO

#include "../arch/generic.arch"
#include "../arch/i686.arch"
#include "../arch/x86_64.arch"

#include "MachDeps.h"

cpu_alias s = maybe arch_error id $ lookup s' $ [
    ("unknown","generic"),
    ("amd64","x86_64"),
    ("i386","i686"),
    ("i486","i686"),
    ("i586","i686")
    ] ++ [ (n,n) | n <- archs ] where s' = map toLower s

archs = ["generic","i686","x86_64"]

arch_map = [
    ("generic",Nothing,arch_generic,[]),
    ("i686",Nothing,arch_i686,[]),
    ("x86_64",Just 64,arch_x86_64,[]),
    ("x86_64",Just 32,arch_i686,["-m32"])
    ]

available_archs = snub $ "ghc":"ghc-64":"ghc-32":[ n | (n,_,_,_) <- arch_map ]  ++ [ n ++ "-" ++ show b |  (n,Just b,_,_) <- arch_map]

primitiveInfo :: Monad m => ExtType -> m PrimType
primitiveInfo et = Map.lookup et primMap

genericPrimitiveInfo :: Monad m => ExtType -> m PrimType
genericPrimitiveInfo et = Map.lookup et primMap


primMap :: Map.Map ExtType PrimType
primMap = Map.fromList [ (primTypeName a,a) | a <- as ] where
    (_,_,as,_) = unsafePerformIO determineArch

isFGrin :: Bool
isFGrin = case optArch options of
    Nothing -> True
    Just o -> "grin" `isPrefixOf` o
{'fraction_non_alphanumeric': 0.14936297099484955, 'fraction_numerical': 0.043914339929520194, 'mean_word_length': 3.641509433962264, 'pattern_counts': {'":': 6, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6969569', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1301, 'n_words': 370}