diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2019-07-04 17:49:11 +0200 |
---|---|---|
committer | Xavier Leroy <xavierleroy@users.noreply.github.com> | 2019-07-17 09:17:28 +0200 |
commit | 633e60ed36c07c4b6cb4b1dc93b9eea312882ceb (patch) | |
tree | 22feeaf195a61a3ffecf280717ddbde60987a5c7 /cfrontend/C2C.ml | |
parent | 10aa130361a5a673a14a7b38ed9c077103f9155f (diff) | |
download | compcert-633e60ed36c07c4b6cb4b1dc93b9eea312882ceb.tar.gz compcert-633e60ed36c07c4b6cb4b1dc93b9eea312882ceb.zip |
Make __builtin_sel available from C source code
It is type-checked like a conditional expression then translated to
a call to the known builtin function.
Diffstat (limited to 'cfrontend/C2C.ml')
-rw-r--r-- | cfrontend/C2C.ml | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index 4d0e52e1..2e6bbe67 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -181,6 +181,11 @@ let builtins_generic = { TInt(IULong, []); TInt(IULong, [])], false); + (* Selection *) + "__builtin_sel", + (TVoid [], + [TInt(C.IBool, [])], + true); (* Annotations *) "__builtin_annot", (TVoid [], @@ -941,6 +946,10 @@ let rec convertExpr env e = Econs(va_list_ptr dst, Econs(va_list_ptr src, Enil)), Tvoid) + | C.ECall({edesc = C.EVar {name = "__builtin_sel"}}, [arg1; arg2; arg3]) -> + ewrap (Ctyping.eselection (convertExpr env arg1) + (convertExpr env arg2) (convertExpr env arg3)) + | C.ECall({edesc = C.EVar {name = "printf"}}, args) when !Clflags.option_interp -> let targs = convertTypArgs env [] args |