[Git][ghc/ghc][master] NCG/LA64: add support for la664 micro architecture
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 5e1cd595 by Peng Fan at 2026-01-14T11:12:26-05:00 NCG/LA64: add support for la664 micro architecture Add '-mla664' flag to LA664, which has some new features: atomic instructions, dbar hints, etc. 'LA464' is the default so that unrecognized instructions are not generated. - - - - - 5 changed files: - compiler/GHC/CmmToAsm/Config.hs - compiler/GHC/Driver/Config/CmmToAsm.hs - compiler/GHC/Driver/DynFlags.hs - compiler/GHC/Driver/Session.hs - docs/users_guide/using.rst Changes: ===================================== compiler/GHC/CmmToAsm/Config.hs ===================================== @@ -48,6 +48,7 @@ data NCGConfig = NCGConfig , ncgEnableInterModuleFarJumps:: !Bool -- ^ Use far-jumps for cross-module jumps. , ncgComputeUnwinding :: !Bool -- ^ Compute block unwinding tables , ncgEnableDeadCodeElimination :: !Bool -- ^ Whether to enable the dead-code elimination + , ncgLa664Enabled :: !Bool -- ^ la664 is equal to isav1.1 } -- | Return Word size ===================================== compiler/GHC/Driver/Config/CmmToAsm.hs ===================================== @@ -66,6 +66,8 @@ initNCGConfig dflags this_mod = NCGConfig _ -> Nothing , ncgAvx512fEnabled = isAvx512fEnabled dflags + , ncgLa664Enabled = isLa664Enabled dflags + , ncgDwarfEnabled = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags > 0 && platformArch (targetPlatform dflags) /= ArchAArch64 , ncgDwarfUnwindings = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags > 0 , ncgDwarfStripBlockInfo = osElfTarget (platformOS (targetPlatform dflags)) && debugLevel dflags < 2 -- We strip out block information when running with -g0 or -g1. ===================================== compiler/GHC/Driver/DynFlags.hs ===================================== @@ -89,7 +89,9 @@ module GHC.Driver.DynFlags ( isAvx512pfEnabled, isFmaEnabled, isBmiEnabled, - isBmi2Enabled + isBmi2Enabled, + -- For LoongArch platform + isLa664Enabled ) where import GHC.Prelude @@ -457,6 +459,7 @@ data DynFlags = DynFlags { avx512f :: Bool, -- Enable AVX-512 instructions. avx512pf :: Bool, -- Enable AVX-512 PreFetch Instructions. fma :: Bool, -- ^ Enable FMA instructions. + la664 :: Bool, -- Enable LA664 instructions -- Constants used to control the amount of optimization done. @@ -740,6 +743,8 @@ defaultDynFlags mySettings = avx512pf = False, -- Use FMA by default on AArch64 fma = (platformArch . sTargetPlatform $ mySettings) == ArchAArch64, + -- For LoongArch, la464 is used by default. + la664 = False, maxInlineAllocSize = 128, maxInlineMemcpyInsns = 32, @@ -1662,6 +1667,11 @@ We handle this as follows: to `AVX2`. -} +-- ----------------------------------------------------------------------------- +-- LA664 +isLa664Enabled :: DynFlags -> Bool +isLa664Enabled dflags = la664 dflags + -- ----------------------------------------------------------------------------- -- BMI2 ===================================== compiler/GHC/Driver/Session.hs ===================================== @@ -218,6 +218,9 @@ module GHC.Driver.Session ( isAvx512pfEnabled, isFmaEnabled, + -- LoongArch: ISA version: la664, la464(default) + isLa664Enabled, + -- * Linker/compiler information useXLinkerRPath, @@ -1729,6 +1732,9 @@ dynamic_flags_deps = [ d { avx512pf = True })) , make_ord_flag defGhcFlag "mfma" (noArg (\d -> d { fma = True })) + + , make_ord_flag defGhcFlag "mla664" (noArg (\d -> d { la664 = True })) + ------ Plugin flags ------------------------------------------------ , make_ord_flag defGhcFlag "fplugin-opt" (hasArg addPluginModuleNameOption) , make_ord_flag defGhcFlag "fplugin-trustworthy" ===================================== docs/users_guide/using.rst ===================================== @@ -1781,6 +1781,17 @@ Some flags only make sense for particular target platforms. multiply-add, which might perform non-IEEE-compliant software emulation on some platforms (depending on the implementation of the C standard library). +.. ghc-flag:: -mla664 + :shortdesc: (LoongArch only) Used for new instructions for la664 uarch + :type: dynamic + :category: platform-options + + :default: off by default, avoid to generate invalid instructions for non-la664 uarchs. + + GHC currently does not use LA664 specific instructions, + so this flag has no effect when used with the :ref:`native code generator <native-code-gen>` + or the :ref:`LLVM backend <llvm-code-gen>`. + Haddock ------- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e1cd595b98fc153beaea795ee079f3f... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/5e1cd595b98fc153beaea795ee079f3f... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)