diff options
author | Peter Wortmann <scpmw@leeds.ac.uk> | 2013-05-29 17:55:12 +0100 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2013-06-27 13:39:11 -0700 |
commit | fa6cbdfb6e5d572dc74622d1c12e259c208321ab (patch) | |
tree | 1cbf43a8991e46e66044fb1395e8edd6ee302867 | |
parent | 8f0ecc0343b0a1c9fcbdf3224b2d9067dd549659 (diff) | |
download | haskell-fa6cbdfb6e5d572dc74622d1c12e259c208321ab.tar.gz |
Use full contents size for arrays
I am not quite sure at what point it makes sense to look at arrays as
pointers, but I ran into at least one use case that strongly suggested
doing it this way (calculating the actual size of structures, to be exact).
-rw-r--r-- | compiler/llvmGen/Llvm/Types.hs | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs index 3ccdfecb14..c93147f4d0 100644 --- a/compiler/llvmGen/Llvm/Types.hs +++ b/compiler/llvmGen/Llvm/Types.hs @@ -317,8 +317,10 @@ llvmWidthInBits _ (LMFloat80) = 80 llvmWidthInBits _ (LMFloat128) = 128 -- Could return either a pointer width here or the width of what -- it points to. We will go with the former for now. +-- PMW: At least judging by the way LLVM outputs constants, pointers +-- should use the former, but arrays the latter. llvmWidthInBits dflags (LMPointer _) = llvmWidthInBits dflags (llvmWord dflags) -llvmWidthInBits dflags (LMArray _ _) = llvmWidthInBits dflags (llvmWord dflags) +llvmWidthInBits dflags (LMArray n t) = n * llvmWidthInBits dflags t llvmWidthInBits dflags (LMVector n ty) = n * llvmWidthInBits dflags ty llvmWidthInBits _ LMLabel = 0 llvmWidthInBits _ LMVoid = 0 |