diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs index 46296d7ccc5fd7c747872eeb8ef403ec4fb0c393..8607501272d0d33e2fff26c97e90a32ca1eb4b9d 100644 --- a/compiler/GHC/CmmToLlvm.hs +++ b/compiler/GHC/CmmToLlvm.hs @@ -224,7 +224,7 @@ cmmMetaLlvmPrelude = do let codel_model_metas = case platformArch platform of -- FIXME: We should not rely on LLVM - ArchLoongArch64 -> [mkCodelModelMeta 3] + ArchLoongArch64 -> [mkCodeModelMeta CMMedium] _ -> [] module_flags_metas <- mkModuleFlagsMeta (stack_alignment_metas ++ codel_model_metas) let metas = tbaa_metas ++ module_flags_metas @@ -249,11 +249,15 @@ mkStackAlignmentMeta :: Integer -> ModuleFlag mkStackAlignmentMeta alignment = ModuleFlag MFBError "override-stack-alignment" (MetaLit $ LMIntLit alignment i32) --- Pass -mcmodel=medium option to LLVM on LoongArch64 -mkCodelModelMeta :: Integer -> ModuleFlag -mkCodelModelMeta codemodel = - ModuleFlag MFBError "Code Model" (MetaLit $ LMIntLit codemodel i32) +-- LLVM's @LLVM::CodeModel::Model@ enumeration +data CodeModel = CMMedium +-- Pass -mcmodel=medium option to LLVM on LoongArch64 +mkCodeModelMeta :: CodeModel -> ModuleFlag +mkCodeModelMeta codemodel = + ModuleFlag MFBError "Code Model" (MetaLit $ LMIntLit n i32) + where + n = case codemodel of CMMedium -> 3 -- as of LLVM 17 -- ----------------------------------------------------------------------------- -- | Marks variables as used where necessary