Commit 20ea4cf4 authored by dterei's avatar dterei
Browse files

LLVM: Update to use new fp ops introduced in 2.7

parent 439cda45
......@@ -155,14 +155,16 @@ instance Show LlvmStatic where
show (LMAdd s1 s2)
= let ty1 = getStatType s1
op = if isFloat ty1 then " fadd (" else " add ("
in if ty1 == getStatType s2
then show ty1 ++ " add (" ++ show s1 ++ "," ++ show s2 ++ ")"
then show ty1 ++ op ++ show s1 ++ "," ++ show s2 ++ ")"
else error $ "LMAdd with different types! s1: "
++ show s1 ++ ", s2: " ++ show s2
show (LMSub s1 s2)
= let ty1 = getStatType s1
op = if isFloat ty1 then " fsub (" else " sub ("
in if ty1 == getStatType s2
then show ty1 ++ " sub (" ++ show s1 ++ "," ++ show s2 ++ ")"
then show ty1 ++ op ++ show s1 ++ "," ++ show s2 ++ ")"
else error $ "LMSub with different types! s1: "
++ show s1 ++ ", s2: " ++ show s2
......@@ -636,10 +638,14 @@ data LlvmMachOp
| LM_MO_Mul -- ^ multiply ..
| LM_MO_UDiv -- ^ unsigned integer or vector division.
| LM_MO_SDiv -- ^ signed integer ..
| LM_MO_FDiv -- ^ floating point ..
| LM_MO_URem -- ^ unsigned integer or vector remainder (mod)
| LM_MO_SRem -- ^ signed ...
| LM_MO_FRem -- ^ floating point ...
| LM_MO_FAdd -- ^ add two floating point or vector values.
| LM_MO_FSub -- ^ subtract two ...
| LM_MO_FMul -- ^ multiply ...
| LM_MO_FDiv -- ^ divide ...
| LM_MO_FRem -- ^ remainder ...
-- | Left shift
| LM_MO_Shl
......@@ -662,9 +668,12 @@ instance Show LlvmMachOp where
show LM_MO_Mul = "mul"
show LM_MO_UDiv = "udiv"
show LM_MO_SDiv = "sdiv"
show LM_MO_FDiv = "fdiv"
show LM_MO_URem = "urem"
show LM_MO_SRem = "srem"
show LM_MO_FAdd = "fadd"
show LM_MO_FSub = "fsub"
show LM_MO_FMul = "fmul"
show LM_MO_FDiv = "fdiv"
show LM_MO_FRem = "frem"
show LM_MO_Shl = "shl"
show LM_MO_LShr = "lshr"
......
......@@ -571,7 +571,7 @@ genMachOp env _ op [x] = case op of
MO_F_Neg w ->
let all0 = LMLitVar $ LMFloatLit (-0) (widthToLlvmFloat w)
in negate (widthToLlvmFloat w) all0 LM_MO_Sub
in negate (widthToLlvmFloat w) all0 LM_MO_FSub
MO_SF_Conv _ w -> fiConv (widthToLlvmFloat w) LM_Sitofp
MO_FS_Conv _ w -> fiConv (widthToLlvmInt w) LM_Fptosi
......@@ -649,9 +649,9 @@ genMachOp env opt op [x, y] = case op of
MO_F_Lt _ -> genBinComp opt LM_CMP_Flt
MO_F_Le _ -> genBinComp opt LM_CMP_Fle
MO_F_Add _ -> genBinMach LM_MO_Add
MO_F_Sub _ -> genBinMach LM_MO_Sub
MO_F_Mul _ -> genBinMach LM_MO_Mul
MO_F_Add _ -> genBinMach LM_MO_FAdd
MO_F_Sub _ -> genBinMach LM_MO_FSub
MO_F_Mul _ -> genBinMach LM_MO_FMul
MO_F_Quot _ -> genBinMach LM_MO_FDiv
MO_And _ -> genBinMach LM_MO_And
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment