diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-08-29 14:51:52 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-08-29 19:08:07 -0400 |
commit | 9d57d8c192cd455aa68a7a0c019df97f68ae015f (patch) | |
tree | 872227cdd8b163148d6c4548e0b6cc1d97d9ee4a /compiler/nativeGen/X86/Regs.hs | |
parent | 779b9e6965416ee08af6eb15354cf09e9f40e0d9 (diff) | |
download | haskell-9d57d8c192cd455aa68a7a0c019df97f68ae015f.tar.gz |
nativeGen: Don't index into linked lists
There were a couple places where we indexed into linked lists of
register names. Replace these with arrays.
Reviewers: austin
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D3893
Diffstat (limited to 'compiler/nativeGen/X86/Regs.hs')
-rw-r--r-- | compiler/nativeGen/X86/Regs.hs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/nativeGen/X86/Regs.hs b/compiler/nativeGen/X86/Regs.hs index 4cb82ea224..8bb36ad722 100644 --- a/compiler/nativeGen/X86/Regs.hs +++ b/compiler/nativeGen/X86/Regs.hs @@ -58,6 +58,8 @@ import DynFlags import Outputable import Platform +import qualified Data.Array as A + -- | regSqueeze_class reg -- Calculuate the maximum number of register colors that could be -- denied to a node of this class due to having this reg @@ -267,13 +269,13 @@ showReg platform n | n >= firstxmm = "%xmm" ++ show (n-firstxmm) | n >= firstfake = "%fake" ++ show (n-firstfake) | n >= 8 = "%r" ++ show n - | otherwise = regNames platform !! n + | otherwise = regNames platform A.! n -regNames :: Platform -> [String] +regNames :: Platform -> A.Array Int String regNames platform = if target32Bit platform - then ["%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp", "%esp"] - else ["%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%rbp", "%rsp"] + then A.listArray (0,8) ["%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "%ebp", "%esp"] + else A.listArray (0,8) ["%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi", "%rbp", "%rsp"] |