llvm-hs-pure-4.0.0.0: Pure Haskell LLVM functionality (no FFI).

Safe HaskellSafe
LanguageHaskell98

LLVM.AST.Constant

Description

A representation of LLVM constants

Synopsis

Documentation

data Constant Source #

http://llvm.org/docs/LangRef.html#constants

N.B. - http://llvm.org/docs/LangRef.html#constant-expressions

Although constant expressions and instructions have many similarites, there are important differences - so they're represented using different types in this AST. At the cost of making it harder to move an code back and forth between being constant and not, this approach embeds more of the rules of what IR is legal into the Haskell types.

Constructors

Int 
Float 
Null 

Fields

Struct 
Array 
Vector 

Fields

Undef 

Fields

BlockAddress 
GlobalReference Type Name 
TokenNone 
Add 
FAdd 
Sub 
FSub 
Mul 
FMul 
UDiv 
SDiv 
FDiv 
URem 
SRem 
FRem 
Shl 
LShr 
AShr 
And 
Or 
Xor 
GetElementPtr 
Trunc 

Fields

ZExt 

Fields

SExt 

Fields

FPToUI 

Fields

FPToSI 

Fields

UIToFP 

Fields

SIToFP 

Fields

FPTrunc 

Fields

FPExt 

Fields

PtrToInt 

Fields

IntToPtr 

Fields

BitCast 

Fields

AddrSpaceCast 

Fields

ICmp 
FCmp 
Select 
ExtractElement 

Fields

InsertElement 
ShuffleVector 
ExtractValue 
InsertValue 

Instances

Eq Constant Source # 
Data Constant Source # 

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Constant -> c Constant #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Constant #

toConstr :: Constant -> Constr #

dataTypeOf :: Constant -> DataType #

dataCast1 :: Typeable (* -> *) t => (forall d. Data d => c (t d)) -> Maybe (c Constant) #

dataCast2 :: Typeable (* -> * -> *) t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Constant) #

gmapT :: (forall b. Data b => b -> b) -> Constant -> Constant #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Constant -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Constant -> r #

gmapQ :: (forall d. Data d => d -> u) -> Constant -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> Constant -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> Constant -> m Constant #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Constant -> m Constant #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Constant -> m Constant #

Ord Constant Source # 
Read Constant Source # 
Show Constant Source # 

signedIntegerValue :: Constant -> Integer Source #

Since LLVM types don't include signedness, there's ambiguity in interpreting an constant as an Integer. The LLVM assembly printer prints integers as signed, but cheats for 1-bit integers and prints them as true or false. That way it circuments the otherwise awkward fact that a twos complement 1-bit number only has the values -1 and 0.

unsignedIntegerValue :: Constant -> Integer Source #

This library's conversion from LLVM C++ objects will always produce integer constants as unsigned, so this function in many cases is not necessary. However, nothing's to keep stop direct construction of an Int with a negative integerValue. There's nothing in principle wrong with such a value - it has perfectly good low order bits like any integer, and will be used as such, likely producing the intended result if lowered to C++. If, however one wishes to interpret an Int of unknown provenance as unsigned, then this function will serve.