cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 430c38701375d7c3a8176218a8536fd83b52a446
parent 4df0c2114cd0afd7aded5e67bd9e9af35b149fab
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 22 Feb 2019 13:16:22 -0800

Implement __builtin_inff

Diffstat:
Mdecl.h | 1+
Mexpr.c | 5+++++
Mscope.c | 1+
Atests/builtin-inff.c | 1+
Atests/builtin-inff.qbe | 1+
5 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/decl.h b/decl.h @@ -20,6 +20,7 @@ enum builtinkind { BUILTINVAEND, BUILTINOFFSETOF, BUILTINALLOCA, + BUILTININFF, }; struct declaration { diff --git a/expr.c b/expr.c @@ -481,6 +481,11 @@ postfixexpr(struct scope *s, struct expression *r) e->builtin.kind = BUILTINALLOCA; e->builtin.arg = exprconvert(assignexpr(s), &typeulong); break; + case BUILTININFF: + e = mkexpr(EXPRCONST, &typefloat, 0); + /* TODO: use INFINITY here when we can handle musl's math.h */ + e->constant.f = strtod("inf", NULL); + break; default: fatal("internal error; unknown builtin"); } diff --git a/scope.c b/scope.c @@ -24,6 +24,7 @@ scopeinit(void) {"__builtin_va_end", {.kind = DECLBUILTIN, .builtin = BUILTINVAEND}}, {"__builtin_offsetof", {.kind = DECLBUILTIN, .builtin = BUILTINOFFSETOF}}, {"__builtin_alloca", {.kind = DECLBUILTIN, .builtin = BUILTINALLOCA}}, + {"__builtin_inff", {.kind = DECLBUILTIN, .builtin = BUILTININFF}}, }; struct builtin *b; diff --git a/tests/builtin-inff.c b/tests/builtin-inff.c @@ -0,0 +1 @@ +float x = __builtin_inff(); diff --git a/tests/builtin-inff.qbe b/tests/builtin-inff.qbe @@ -0,0 +1 @@ +export data $x = align 4 { s s_inf, }