From 1276aa3fa5219898ddd1764579ade0c28995973b Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 1 Oct 2004 09:49:14 +0000 Subject: [PATCH] [project @ 2004-10-01 09:49:14 by simonpj] Generate in the @size suffix for a stdcall symbol properly. --- ghc/compiler/codeGen/CgForeignCall.hs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ghc/compiler/codeGen/CgForeignCall.hs b/ghc/compiler/codeGen/CgForeignCall.hs index 9a8ef9e..1f25faf 100644 --- a/ghc/compiler/codeGen/CgForeignCall.hs +++ b/ghc/compiler/codeGen/CgForeignCall.hs @@ -92,14 +92,23 @@ emitForeignCall results (CCall (CCallSpec target cconv safety)) args live (call_args, cmm_target) = case target of StaticTarget lbl -> (args, CmmLit (CmmLabel - (mkForeignLabel lbl Nothing False))) - -- ToDo: what about the size here? - -- it is currently tacked on by the NCG. + (mkForeignLabel lbl call_size False))) DynamicTarget -> case args of (fn,_):rest -> (rest, fn) the_call vols = CmmCall (CmmForeignCall cmm_target cconv) results call_args (Just vols) + -- in the stdcall calling convention, the symbol needs @size appended + -- to it, where size is the total number of bytes of arguments. We + -- attach this info to the CLabel here, and the CLabel pretty printer + -- will generate the suffix when the label is printed. + call_size + | StdCallConv <- cconv = Just (sum (map (arg_size.cmmExprRep.fst) args)) + | otherwise = Nothing + + -- ToDo: this might not be correct for 64-bit API + arg_size rep = max (machRepByteWidth rep) wORD_SIZE + emitForeignCall results (DNCall _) args live = panic "emitForeignCall: DNCall" -- 1.7.10.4