Handle both addl and subl for stack increases.
GCC seems to very occasionally generate addl -N rather than subl N. Also don't allow subl -N any more -- if it's adjusting the stack pointer back up, that doesn't mean it's going to use any less of the stack...
This commit is contained in:
parent
5156626ab0
commit
9c2a6b6656
|
@ -71,23 +71,18 @@ parseAsmLine s
|
||||||
matchInc :: String -> Maybe AsmItem
|
matchInc :: String -> Maybe AsmItem
|
||||||
matchInc s
|
matchInc s
|
||||||
= case matchRegex incdecRE s of
|
= case matchRegex incdecRE s of
|
||||||
Just [v] -> Just $ AsmStackInc (parseVal v)
|
Just [_, v] -> Just $ AsmStackInc (parseVal v)
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
where
|
where
|
||||||
-- The x86 stack goes downwards, so subl makes the stack deeper.
|
-- The x86 stack goes downwards, so subl makes the stack deeper.
|
||||||
incdecRE = mkRegex "^subl (.*), %esp$"
|
-- GCC will sometimes generate "addl $-n" rather than "subl $n".
|
||||||
|
incdecRE = mkRegex "^(subl \\$|addl \\$-)([0-9]+), %esp$"
|
||||||
|
|
||||||
parseVal :: String -> Int
|
parseVal :: String -> Int
|
||||||
-- The numbers can be negative:
|
parseVal s
|
||||||
parseVal ('$':'-':s)
|
|
||||||
= case readDec s of
|
|
||||||
[(v, "")] -> -v
|
|
||||||
_ -> error $ "Don't know how to parse assembly literal: -" ++ s
|
|
||||||
parseVal ('$':s)
|
|
||||||
= case readDec s of
|
= case readDec s of
|
||||||
[(v, "")] -> v
|
[(v, "")] -> v
|
||||||
_ -> error $ "Don't know how to parse assembly literal: " ++ s
|
_ -> error $ "Don't know how to parse assembly literal: " ++ s
|
||||||
parseVal s = error $ "Really don't know how to parse assembly literal: " ++ s
|
|
||||||
|
|
||||||
matchPush :: String -> Maybe AsmItem
|
matchPush :: String -> Maybe AsmItem
|
||||||
matchPush s
|
matchPush s
|
||||||
|
|
Loading…
Reference in New Issue
Block a user