diff options
author | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-05-02 07:40:56 +0000 |
---|---|---|
committer | xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e> | 2010-05-02 07:40:56 +0000 |
commit | 3fb4ee15ed74c55923fe702a130d77120a471ca3 (patch) | |
tree | d315dcd8e4338ee2dbc8643473021b6e38fb51c9 /cfrontend/C2Clight.ml | |
parent | 551b52e3b0ddc7a06358f1246b448664a59c86b4 (diff) | |
download | compcert-3fb4ee15ed74c55923fe702a130d77120a471ca3.tar.gz compcert-3fb4ee15ed74c55923fe702a130d77120a471ca3.zip |
Add "fabs" (floating-point absolute value) as a unary operator in
Clight and C#minor. Recognize __builtin_fabs and turn it into this operator.
git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@1329 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'cfrontend/C2Clight.ml')
-rw-r--r-- | cfrontend/C2Clight.ml | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cfrontend/C2Clight.ml b/cfrontend/C2Clight.ml index 6fc9b5ca..46242e0f 100644 --- a/cfrontend/C2Clight.ml +++ b/cfrontend/C2Clight.ml @@ -371,7 +371,14 @@ let volatile_write_fun ty = let convertTopExpr env e = match e.edesc with | C.EBinop(C.Oassign, lhs, {edesc = C.ECall(fn, args)}, _) -> - convertFuncall env (Some (convertExpr env lhs)) fn args + (* Recognize __builtin_fabs and turn it into Clight operator *) + begin match fn, args with + | {edesc = C.EVar {name = "__builtin_fabs"}}, [arg1] -> + Sassign(convertExpr env lhs, + Expr(Eunop(Ofabs, convertExpr env arg1), Tfloat F64)) + | _ -> + convertFuncall env (Some (convertExpr env lhs)) fn args + end | C.EBinop(C.Oassign, lhs, rhs, _) -> if Cutil.is_composite_type env lhs.etyp then unsupported "assignment between structs or between unions"; @@ -808,6 +815,9 @@ let builtins_generic = { "__builtin_va_list", C.TPtr(C.TVoid [], []) ]; functions = [ + (* Floating-point absolute value *) + "__builtin_fabs", + (TFloat(FDouble, []), [TFloat(FDouble, [])], false); (* The volatile read/volatile write functions *) "__builtin_volatile_read_int8unsigned", (TInt(IUChar, []), [TPtr(TVoid [], [])], false); |