Skip to content
  • sheaf's avatar
    4f3618d8
    The X86 SIMD patch. · 4f3618d8
    sheaf authored and Marge Bot's avatar Marge Bot committed
    This commit adds support for 128 bit wide SIMD vectors and vector
    operations to GHC's X86 native code generator.
    
    Main changes:
    
      - Introduction of vector formats (`GHC.CmmToAsm.Format`)
      - Introduction of 128-bit virtual register (`GHC.Platform.Reg`),
        and removal of unused Float virtual register.
      - Refactor of `GHC.Platform.Reg.Class.RegClass`: it now only contains
        two classes, `RcInteger` (for general purpose registers) and `RcFloatOrVector`
        (for registers that can be used for scalar floating point values as well
        as vectors).
      - Modify `GHC.CmmToAsm.X86.Instr.regUsageOfInstr` to keep track
        of which format each register is used at, so that the register
        allocator can know if it needs to spill the entire vector register
        or just the lower 64 bits.
      - Modify spill/load/reg-2-reg code to account for vector registers
        (`GHC.CmmToAsm.X86.Instr.{mkSpillInstr, mkLoadInstr, mkRegRegMoveInstr, takeRegRegMoveInstr}`).
      - Modify the register allocator code (`GHC.CmmToAsm.Reg.*`) to propagate
        the format we are storing in any given register, for instance changing
        `Reg` to `RegFormat` or `GlobalReg` to `GlobalRegUse`.
      - Add logic to lower vector `MachOp`s to X86 assembly
        (see `GHC.CmmToAsm.X86.CodeGen`)
      - Minor cleanups to genprimopcode, to remove the llvm_only attribute
        which is no longer applicable.
    
    Tests for this feature are provided in the "testsuite/tests/simd" directory.
    
    Fixes #7741
    
    Keeping track of register formats adds a small memory overhead to the
    register allocator (in particular, regUsageOfInstr now allocates more
    to keep track of the `Format` each register is used at). This explains
    the following metric increases.
    
    -------------------------
    Metric Increase:
        T12707
        T13035
        T13379
        T3294
        T4801
        T5321FD
        T5321Fun
        T783
    -------------------------
    4f3618d8
    The X86 SIMD patch.
    sheaf authored and Marge Bot's avatar Marge Bot committed
    This commit adds support for 128 bit wide SIMD vectors and vector
    operations to GHC's X86 native code generator.
    
    Main changes:
    
      - Introduction of vector formats (`GHC.CmmToAsm.Format`)
      - Introduction of 128-bit virtual register (`GHC.Platform.Reg`),
        and removal of unused Float virtual register.
      - Refactor of `GHC.Platform.Reg.Class.RegClass`: it now only contains
        two classes, `RcInteger` (for general purpose registers) and `RcFloatOrVector`
        (for registers that can be used for scalar floating point values as well
        as vectors).
      - Modify `GHC.CmmToAsm.X86.Instr.regUsageOfInstr` to keep track
        of which format each register is used at, so that the register
        allocator can know if it needs to spill the entire vector register
        or just the lower 64 bits.
      - Modify spill/load/reg-2-reg code to account for vector registers
        (`GHC.CmmToAsm.X86.Instr.{mkSpillInstr, mkLoadInstr, mkRegRegMoveInstr, takeRegRegMoveInstr}`).
      - Modify the register allocator code (`GHC.CmmToAsm.Reg.*`) to propagate
        the format we are storing in any given register, for instance changing
        `Reg` to `RegFormat` or `GlobalReg` to `GlobalRegUse`.
      - Add logic to lower vector `MachOp`s to X86 assembly
        (see `GHC.CmmToAsm.X86.CodeGen`)
      - Minor cleanups to genprimopcode, to remove the llvm_only attribute
        which is no longer applicable.
    
    Tests for this feature are provided in the "testsuite/tests/simd" directory.
    
    Fixes #7741
    
    Keeping track of register formats adds a small memory overhead to the
    register allocator (in particular, regUsageOfInstr now allocates more
    to keep track of the `Format` each register is used at). This explains
    the following metric increases.
    
    -------------------------
    Metric Increase:
        T12707
        T13035
        T13379
        T3294
        T4801
        T5321FD
        T5321Fun
        T783
    -------------------------
Loading