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
|
|
| 31 | 31 | |
| 32 | 32 | -- | Llvm Types |
| 33 | 33 | data 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 |
| 45 | 46 | |
| 46 | 47 | -- | Function type, used to create pointers to functions |
| 47 | 48 | | LMFunction LlvmFunctionDecl |
| 48 | 49 | deriving (Eq) |
| 49 | 50 | |
| 50 | 51 | instance 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) ++ "}>" |
| 61 | 63 | |
| 62 | 64 | show (LMFunction (LlvmFunctionDecl _ _ _ r varg p _)) |
| 63 | 65 | = let varg' = case varg of |
| … |
… |
|
| 295 | 297 | -- it points to. We will go with the former for now. |
| 296 | 298 | llvmWidthInBits (LMPointer _) = llvmWidthInBits llvmWord |
| 297 | 299 | llvmWidthInBits (LMArray _ _) = llvmWidthInBits llvmWord |
| | 300 | llvmWidthInBits (LMVector _ _) = llvmWidthInBits llvmWord |
| 298 | 301 | llvmWidthInBits LMLabel = 0 |
| 299 | 302 | llvmWidthInBits LMVoid = 0 |
| 300 | 303 | llvmWidthInBits (LMStruct tys) = sum $ map llvmWidthInBits tys |