From: adr <adr@SDF.ORG>
To: 9fans@9fans.net
Subject: [9fans] Conversion of constants in C compiler
Date: Mon, 6 Jun 2022 00:35:47 +0000 (UTC) [thread overview]
Message-ID: <3df37b2-6a4a-fdfb-7bec-218471d6cb8@SDF.ORG> (raw)
Building cmd I noticed that the case of sizeof(int) = sizeof(long)
(which is the case in all compilers) wasn't managed with my changes.
I wonder if this logic mess could be shortened without making
impossible to read the 'if' conditions without throwing up (I've
tried).
I've compiled on arm the libraries, cmd and kernel (except ape)
without any problem.
adr.
/sys/src/cmd/cc/lex.c
[...]
vv = yylval.vval;
if(c1 & Numvlong ||
(uvlong)convvtox(vv, TUVLONG) > convvtox(vv, TULONG)){
/* unsigned suffix or hex occupying the sing bit */
if((c1 & Numuns) || convvtox(vv, TVLONG) < 0 && (c1 & Numdec) == 0) {
c = LUVLCONST;
t = TUVLONG;
goto nret;
}
c = LVLCONST;
t = TVLONG;
goto nret;
}
if(c1 & Numlong ||
(uvlong)convvtox(vv, TULONG) > convvtox(vv, TUINT)){
if((c1 & Numuns) || convvtox(vv, TLONG) < 0 && (c1 & Numdec) == 0) {
c = LULCONST;
t = TULONG;
goto nret;
}
/* decimal occupying the sing bit */
if(convvtox(vv, TLONG) < 0 && (c1 & Numdec)) {
c = LVLCONST;
t = TVLONG;
goto nret;
}
c = LLCONST;
t = TLONG;
goto nret;
}
if((c1 & Numuns) || convvtox(vv, TINT) < 0 && (c1 & Numdec) == 0) {
c = LUCONST;
t = TUINT;
goto nret;
}
if(convvtox(vv, TINT) < 0 && (c1 & Numdec)) {
/* size(int) = size(long) */
if(convvtox(vv, TLONG) < 0) {
c = LVLCONST;
t = TVLONG;
goto nret;
}
c = LLCONST;
t = TLONG;
goto nret;
}
c = LCONST;
t = TINT;
goto nret;
[...]
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/T4bced580971a40a2-Mda3d0c619c734bb0e1cf708c
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
next reply other threads:[~2022-06-06 0:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 0:35 adr [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-04-20 10:19 adr
2022-04-20 11:38 ` Charles Forsyth
2022-04-20 14:37 ` adr
2022-04-20 14:37 ` ori
2022-04-21 7:54 ` adr
2022-04-21 15:29 ` ori
2022-04-28 1:10 ` ori
2022-05-01 12:03 ` adr
2022-04-28 2:43 ` ori
2022-04-28 3:12 ` ori
2022-05-01 12:35 ` adr
2022-05-09 19:31 ` adr
2022-05-10 13:06 ` adr
2022-05-10 14:48 ` adr
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3df37b2-6a4a-fdfb-7bec-218471d6cb8@SDF.ORG \
--to=adr@sdf.org \
--cc=9fans@9fans.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).