Ticket #5506: 0001-LLVM-Add-LMVector-ctor-to-LlvmType-trac-5506.patch

File 0001-LLVM-Add-LMVector-ctor-to-LlvmType-trac-5506.patch, 3.6 KB (added by erikd, 20 months ago)

LLVM: Add LMVector ctor to LlvmType?; trac #5506.

  • compiler/llvmGen/Llvm/Types.hs

    From f6933e4911641397ced1812edeba2fd662a3e186 Mon Sep 17 00:00:00 2001
    From: Erik de Castro Lopo <erikd@mega-nerd.com>
    Date: Sat, 24 Sep 2011 17:29:59 +1000
    Subject: [PATCH] LLVM: Add LMVector ctor to LlvmType; trac #5506.
    
    This is the first tentaive step towards generating SIMD vector
    instructions like MMX/SSE/SSE2.
    ---
     compiler/llvmGen/Llvm/Types.hs |   45 +++++++++++++++++++++------------------
     1 files changed, 24 insertions(+), 21 deletions(-)
    
    diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs
    index 1013426..0f8cece 100644
    a b  
    3131 
    3232-- | Llvm Types 
    3333data LlvmType 
    34   = LMInt Int            -- ^ An integer with a given width in bits. 
    35   | LMFloat              -- ^ 32 bit floating point 
    36   | LMDouble             -- ^ 64 bit floating point 
    37   | LMFloat80            -- ^ 80 bit (x86 only) floating point 
    38   | LMFloat128           -- ^ 128 bit floating point 
    39   | LMPointer LlvmType   -- ^ A pointer to a 'LlvmType' 
    40   | LMArray Int LlvmType -- ^ An array of 'LlvmType' 
    41   | LMLabel              -- ^ A 'LlvmVar' can represent a label (address) 
    42   | LMVoid               -- ^ Void type 
    43   | LMStruct [LlvmType]  -- ^ Structure type 
    44   | LMAlias LlvmAlias    -- ^ A type alias 
     34  = LMInt Int             -- ^ An integer with a given width in bits. 
     35  | LMFloat               -- ^ 32 bit floating point 
     36  | LMDouble              -- ^ 64 bit floating point 
     37  | LMFloat80             -- ^ 80 bit (x86 only) floating point 
     38  | LMFloat128            -- ^ 128 bit floating point 
     39  | LMPointer LlvmType    -- ^ A pointer to a 'LlvmType' 
     40  | LMArray Int LlvmType  -- ^ An array of 'LlvmType' 
     41  | LMVector Int LlvmType -- ^ An vector of 'LlvmType' (for SIMD). The LlvmType must be primitive. 
     42  | LMLabel               -- ^ A 'LlvmVar' can represent a label (address) 
     43  | LMVoid                -- ^ Void type 
     44  | LMStruct [LlvmType]   -- ^ Structure type 
     45  | LMAlias LlvmAlias     -- ^ A type alias 
    4546 
    4647  -- | Function type, used to create pointers to functions 
    4748  | LMFunction LlvmFunctionDecl 
    4849  deriving (Eq) 
    4950 
    5051instance Show LlvmType where 
    51   show (LMInt size    ) = "i" ++ show size 
    52   show (LMFloat       ) = "float" 
    53   show (LMDouble      ) = "double" 
    54   show (LMFloat80     ) = "x86_fp80" 
    55   show (LMFloat128    ) = "fp128" 
    56   show (LMPointer x   ) = show x ++ "*" 
    57   show (LMArray nr tp ) = "[" ++ show nr ++ " x " ++ show tp ++ "]" 
    58   show (LMLabel       ) = "label" 
    59   show (LMVoid        ) = "void" 
    60   show (LMStruct tys  ) = "<{" ++ (commaCat tys) ++ "}>" 
     52  show (LMInt size     ) = "i" ++ show size 
     53  show (LMFloat        ) = "float" 
     54  show (LMDouble       ) = "double" 
     55  show (LMFloat80      ) = "x86_fp80" 
     56  show (LMFloat128     ) = "fp128" 
     57  show (LMPointer x    ) = show x ++ "*" 
     58  show (LMArray nr tp  ) = "[" ++ show nr ++ " x " ++ show tp ++ "]" 
     59  show (LMVector nr tp ) = "<" ++ show nr ++ " x " ++ show tp ++ ">" 
     60  show (LMLabel        ) = "label" 
     61  show (LMVoid         ) = "void" 
     62  show (LMStruct tys   ) = "<{" ++ (commaCat tys) ++ "}>" 
    6163 
    6264  show (LMFunction (LlvmFunctionDecl _ _ _ r varg p _)) 
    6365    = let varg' = case varg of 
     
    295297-- it points to. We will go with the former for now. 
    296298llvmWidthInBits (LMPointer _)   = llvmWidthInBits llvmWord 
    297299llvmWidthInBits (LMArray _ _)   = llvmWidthInBits llvmWord 
     300llvmWidthInBits (LMVector _ _)  = llvmWidthInBits llvmWord 
    298301llvmWidthInBits LMLabel         = 0 
    299302llvmWidthInBits LMVoid          = 0 
    300303llvmWidthInBits (LMStruct tys)  = sum $ map llvmWidthInBits tys