From 29bba59319af1acb45d8404ca30a46e2b10d97b4 Mon Sep 17 00:00:00 2001 From: Wang Xin <wangxin03@loongson.cn> Date: Sat, 23 Nov 2024 08:02:02 +0000 Subject: [PATCH] Add new type for codemodel --- compiler/GHC/CmmToLlvm.hs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/compiler/GHC/CmmToLlvm.hs b/compiler/GHC/CmmToLlvm.hs index 46296d7ccc5f..8607501272d0 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 -- GitLab