1. 28 Nov, 2017 1 commit
    • Ben Gamari's avatar
      cmm: Use LocalBlockLabel instead of AsmTempLabel to represent blocks · 048a9138
      Ben Gamari authored
      blockLbl was originally changed in 8b007abb to
      use mkTempAsmLabel to fix an inconsistency resulting in #14221. However, this
      breaks the C code generator, which doesn't support AsmTempLabels (#14454).
      Instead let's try going the other direction: use a new CLabel variety,
      LocalBlockLabel. Then we can teach the C code generator to deal with
      these as well.
  2. 22 Nov, 2017 1 commit
  3. 15 Nov, 2017 1 commit
    • John Ky's avatar
      Add new mbmi and mbmi2 compiler flags · f5dc8ccc
      John Ky authored
      This adds support for the bit deposit and extraction operations provided
      by the BMI and BMI2 instruction set extensions on modern amd64 machines.
      Test Plan: Validate
      Reviewers: austin, simonmar, bgamari, hvr, goldfire, erikd
      Reviewed By: bgamari
      Subscribers: goldfire, erikd, trommler, newhoggy, rwbarton, thomie
      GHC Trac Issues: #14206
      Differential Revision: https://phabricator.haskell.org/D4063
  4. 09 Nov, 2017 1 commit
    • Peter Trommler's avatar
      Fix PPC NCG after blockID patch · f8e7fece
      Peter Trommler authored
      Commit rGHC8b007ab assigns the same label to the first basic block
      of a proc and to the proc entry point. This violates the PPC 64-bit ELF
      v. 1.9 and v. 2.0 ABIs and leads to duplicate symbols.
      This patch fixes duplicate symbols caused by block labels
      In commit rGHCd7b8da1 an info table label is generated from a block id.
      Getting the entry label from that info label leads to an undefined
      symbol because a suffix "_entry" that is not present in the block label.
      To fix that issue add a new info table label flavour for labels
      derived from block ids. Converting such a label with toEntryLabel
      produces the original block label.
      Fixes #14311
      Test Plan: ./validate
      Reviewers: austin, bgamari, simonmar, erikd, hvr, angerman
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #14311
      Differential Revision: https://phabricator.haskell.org/D4149
  5. 02 Nov, 2017 1 commit
    • Peter Trommler's avatar
      PPC NCG: Impl branch prediction, atomic ops. · 1130c67b
      Peter Trommler authored
      Implement AtomicRMW ops, atomic read, atomic write
      in PowerPC native code generator. Also implement
      branch prediction because we need it in atomic ops
      This patch improves the issue in #12537 a bit but
      does not fix it entirely.
      The fallback operations for atomicread and atomicwrite
      in libraries/ghc-prim/cbits/atomic.c are incorrect.
      This patch avoids those functions by implementing the
      operations directly in the native code generator. This
      is also what the x86/amd64 NCG and the LLVM backend
      Test Plan: validate on AIX and PowerPC (32-bit) Linux
      Reviewers: erikd, hvr, austin, bgamari, simonmar
      Reviewed By: hvr, bgamari
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #12537
      Differential Revision: https://phabricator.haskell.org/D3984
  6. 30 Oct, 2017 3 commits
  7. 25 Oct, 2017 1 commit
    • Tobias Dammers's avatar
      Performance improvements linear regAlloc (#7258) · df636682
      Tobias Dammers authored
      When allocating and potentially spilling registers, we need to check
      the desired allocations against current allocations to decide where we
      can spill to, cq. which allocations we can toss and if so, how.
      Previously, this was done by walking the Cartesian product of the
      current allocations (`assig`) and the allocations to keep (`keep`),
      which has quadratic complexity. This patch introduces two improvements:
      1. pre-filter the `assig` list, because we are only interested in two
      types of allocations (in register, and in register+memory), which will
      only make up a small and constant portion of the list; and
      2. use set / map operations instead of lists, which reduces algorithmic
      Reviewers: austin, bgamari
      Reviewed By: bgamari
      Subscribers: rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D4109
  8. 26 Sep, 2017 1 commit
  9. 19 Sep, 2017 2 commits
  10. 07 Sep, 2017 2 commits
  11. 06 Sep, 2017 1 commit
    • Moritz Angermann's avatar
      Clean up opt and llc · 22733532
      Moritz Angermann authored
      The LLVM backend shells out to LLVMs `opt` and `llc` tools. This clean
      up introduces a shared data structure to carry the arguments we pass to
      each tool so that corresponding flags are next to each other. It drops
      the hard coded data layouts in favor of using `-mtriple` and have LLVM
      infer them. Furthermore we add `clang` as a proper tool, so we don't
      rely on assuming that `clang` is called `clang` on the `PATH` when using
      `clang` as the assembler.  Finally this diff also changes the type of
      `optLevel` from `Int` to `Word`, as we do not have negative optimization
      Reviewers: erikd, hvr, austin, rwbarton, bgamari, kavon
      Reviewed By: kavon
      Subscribers: michalt, Ericson2314, ryantrinkle, dfeuer, carter, simonpj,
      kavon, simonmar, thomie, erikd, snowleopard
      Differential Revision: https://phabricator.haskell.org/D3352
  12. 31 Aug, 2017 1 commit
    • Simon Peyton Jones's avatar
      Add debugPprType · 805b29bb
      Simon Peyton Jones authored
      We pretty-print a type by converting it to an IfaceType and
      pretty-printing that.  But
       (a) that's a bit indirect, and
       (b) delibrately loses information about (e.g.) the kind
            on the /occurrences/ of a type variable
      So this patch implements debugPprType, which pretty prints
      the type directly, with no fancy formatting.  It's just used
      for debugging.
      I took the opportunity to refactor the debug-pretty-printing
      machinery a little.  In particular, define these functions
      and use them:
        ifPprDeubug :: SDoc -> SDOc -> SDoc
          -- Says what to do with and without -dppr-debug
        whenPprDebug :: SDoc -> SDoc
          -- Says what to do with  -dppr-debug; without is empty
        getPprDebug :: (Bool -> SDoc) -> SDoc
      getPprDebug used to be called sdocPprDebugWith
      whenPprDebug used to be called ifPprDebug
      So a lot of files get touched in a very mechanical way
  13. 29 Aug, 2017 1 commit
  14. 24 Aug, 2017 1 commit
  15. 22 Aug, 2017 1 commit
  16. 01 Aug, 2017 1 commit
    • Ryan Scott's avatar
      Drop GHC 7.10 compatibility · c13720c8
      Ryan Scott authored
      GHC 8.2.1 is out, so now GHC's support window only extends back to GHC
      8.0. This means we can delete gobs of code that was only used for GHC
      7.10 support. Hooray!
      Test Plan: ./validate
      Reviewers: hvr, bgamari, austin, goldfire, simonmar
      Reviewed By: bgamari
      Subscribers: Phyx, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3781
  17. 31 Jul, 2017 1 commit
  18. 26 Jul, 2017 1 commit
  19. 11 Jul, 2017 1 commit
    • Ben Gamari's avatar
      Use correct section types syntax for architecture · 9b9f978f
      Ben Gamari authored
      Previously GHC would always assume that section types began with `@` while
      producing assembly, which is not true. For instance, in ARM assembly syntax
      section types begin with `%`. This abstracts out section type pretty-printing
      and adjusts it to correctly account for the target architectures assembly
      Reviewers: austin, hvr, Phyx
      Reviewed By: Phyx
      Subscribers: Phyx, rwbarton, thomie, erikd
      GHC Trac Issues: #13937
      Differential Revision: https://phabricator.haskell.org/D3712
  20. 07 Jul, 2017 1 commit
    • Tamar Christina's avatar
      Implement split-sections support for windows. · bd4fdc6a
      Tamar Christina authored
      Initial implementation of split-section on Windows.
      This also corrects section namings and uses the platform
      convention of `$` instead of `.` to separate sections.
      Implementation is based on @awson's patches to binutils.
      Binutils requires some extra help when compiling the libraries
      for GHCi usage. We drop the `-T` and use implicit scripts to amend
      the linker scripts instead of replacing it.
      Because of these very large GHCi object files, we need big-obj support,
      which will be added by another patch.
      Test Plan: ./validate
      Reviewers: awson, austin, bgamari
      Subscribers: dfeuer, rwbarton, thomie, snowleopard, #ghc_windows_task_force
      GHC Trac Issues: #12913
      Differential Revision: https://phabricator.haskell.org/D3383
  21. 26 Jun, 2017 1 commit
    • Ben Gamari's avatar
      DWARF: Use .short to render half-machine-words · 904255eb
      Ben Gamari authored
      The binutils documentation states that .short is a synonym for .word,
      which I assumed to mean "machine word", leading me to believe that we
      needed to use .hword to render half-machine-words. However, Darwin's
      toolchain doesn't understand .hword, so there we instead used .short.
      However, as it turns out the binutils documentation confusingly uses
      "word" to refer to a 16-bit word, so .short should work fine. Moreover,
      LLVM's internal assembler also doesn't understand .hword, so using
      .short consistently simplies things remarkably.
      Test Plan: Validate using binutils and LLVM internal assembler,
      validate on Darwin
      Reviewers: niteria, austin
      Reviewed By: niteria
      Subscribers: rwbarton, thomie
      GHC Trac Issues: #13866
      Differential Revision: https://phabricator.haskell.org/D3667
  22. 23 Jun, 2017 1 commit
    • Michal Terepeta's avatar
      Hoopl: remove dependency on Hoopl package · 42eee6ea
      Michal Terepeta authored
      This copies the subset of Hoopl's functionality needed by GHC to
      `cmm/Hoopl` and removes the dependency on the Hoopl package.
      The main motivation for this change is the confusing/noisy interface
      between GHC and Hoopl:
      - Hoopl has `Label` which is GHC's `BlockId` but different than
        GHC's `CLabel`
      - Hoopl has `Unique` which is different than GHC's `Unique`
      - Hoopl has `Unique{Map,Set}` which are different than GHC's
      - GHC has its own specialized copy of `Dataflow`, so `cmm/Hoopl` is
        needed just to filter the exposed functions (filter out some of the
        Hoopl's and add the GHC ones)
      With this change, we'll be able to simplify this significantly.
      It'll also be much easier to do invasive changes (Hoopl is a public
      package on Hackage with users that depend on the current behavior)
      This should introduce no changes in functionality - it merely
      copies the relevant code.
      Signed-off-by: Michal Terepeta's avatarMichal Terepeta <michal.terepeta@gmail.com>
      Test Plan: ./validate
      Reviewers: austin, bgamari, simonmar
      Reviewed By: bgamari, simonmar
      Subscribers: simonpj, kavon, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3616
  23. 02 Jun, 2017 1 commit
    • Ryan Scott's avatar
      Use lengthIs and friends in more places · a786b136
      Ryan Scott authored
      While investigating #12545, I discovered several places in the code
      that performed length-checks like so:
      length ts == 4
      This is not ideal, since the length of `ts` could be much longer than 4,
      and we'd be doing way more work than necessary! There are already a slew
      of helper functions in `Util` such as `lengthIs` that are designed to do
      this efficiently, so I found every place where they ought to be used and
      did just that. I also defined a couple more utility functions for list
      length that were common patterns (e.g., `ltLength`).
      Test Plan: ./validate
      Reviewers: austin, hvr, goldfire, bgamari, simonmar
      Reviewed By: bgamari, simonmar
      Subscribers: goldfire, rwbarton, thomie
      Differential Revision: https://phabricator.haskell.org/D3622
  24. 01 May, 2017 1 commit
  25. 28 Apr, 2017 1 commit
  26. 25 Apr, 2017 1 commit
    • Peter Trommler's avatar
      PPC NCG: Implement callish prim ops · 89a3241f
      Peter Trommler authored
      Provide PowerPC optimised implementations of callish prim ops.
      The generic implementation of quotient remainder prim ops uses
      a division and a remainder operation. There is no remainder on
      PowerPC and so we need to implement remainder "by hand" which
      results in a duplication of the divide operation when using the
      generic code.
      Avoid this duplication by implementing the prim op in the native
      code generator.
      Use PowerPC's instructions for long multiplication.
      Addition and subtraction
      Use PowerPC add/subtract with carry/overflow instructions
      MO_Clz and MO_Ctz
      Use PowerPC's CNTLZ instruction and implement count trailing
      zeros using count leading zeros
      Implement an algorithm given by Henry Warren in "Hacker's Delight"
      using PowerPC divide instruction. TODO: Use long division instructions
      when available (POWER7 and later).
      Test Plan: validate on AIX and 32-bit Linux
      Reviewers: simonmar, erikd, hvr, austin, bgamari
      Reviewed By: erikd, hvr, bgamari
      Subscribers: trofi, kgardas, thomie
      Differential Revision: https://phabricator.haskell.org/D2973
  27. 23 Apr, 2017 1 commit
  28. 05 Apr, 2017 2 commits
  29. 24 Mar, 2017 2 commits
    • rwbarton's avatar
      x86 nativeGen: Fix test with mask in range [128,255] (#13425) · caf94b06
      rwbarton authored
      My commit bdb0c43c optimized the encoding of instructions to test
      tag bits, but it did not always set exactly the same condition codes
      since the testb instruction does a single-byte comparison, rather
      than a full-word comparison.
      It would be correct to optimize the expression `x .&. 128 > 0` to
      the sequence
          testb $128, %al
          seta %al         ; note: 'a' for unsigned comparison,
                           ; not 'g' for signed comparison
      but the pretty-printer is not the right place to make this kind of
      context-sensitive optimization.
      Test Plan: harbormaster
      Reviewers: trofi, austin, bgamari, dfeuer
      Reviewed By: trofi, dfeuer
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D3359
    • Gabor Greif's avatar
      Typos in comments (notes too) [ci skip] · 1dd60ac9
      Gabor Greif authored
  30. 14 Mar, 2017 1 commit
  31. 10 Mar, 2017 1 commit
  32. 07 Mar, 2017 1 commit
  33. 01 Mar, 2017 1 commit
    • David Feuer's avatar
      Upgrade UniqSet to a newtype · cbe569a5
      David Feuer authored
      The fundamental problem with `type UniqSet = UniqFM` is that `UniqSet`
      has a key invariant `UniqFM` does not. For example, `fmap` over
      `UniqSet` will generally produce nonsense.
      * Upgrade `UniqSet` from a type synonym to a newtype.
      * Remove unused and shady `extendVarSet_C` and `addOneToUniqSet_C`.
      * Use cached unique in `tyConsOfType` by replacing
        `unitNameEnv (tyConName tc) tc` with `unitUniqSet tc`.
      Reviewers: austin, hvr, goldfire, simonmar, niteria, bgamari
      Reviewed By: niteria
      Subscribers: thomie
      Differential Revision: https://phabricator.haskell.org/D3146
  34. 23 Feb, 2017 1 commit