summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--6/simp.c10
-rw-r--r--parse/infer.c6
-rw-r--r--test/bigliteral.myr2
3 files changed, 14 insertions, 4 deletions
diff --git a/6/simp.c b/6/simp.c
index 1bf0939..fd6a50b 100644
--- a/6/simp.c
+++ b/6/simp.c
@@ -1256,9 +1256,17 @@ static Node *rval(Simp *s, Node *n, Node *dst)
break;
case Olit:
switch (args[0]->lit.littype) {
- case Lchr: case Lbool: case Lint: case Llbl:
+ case Lchr: case Lbool: case Llbl:
r = n;
break;
+ case Lint:
+ /* we can only have up to 4 byte immediates, but they
+ * can be moved into 64 bit regs */
+ if (args[0]->lit.intval < 0xffffffff)
+ r = n;
+ else
+ r = simplit(s, n, &s->blobs, &s->nblobs);
+ break;
case Lstr: case Lflt:
r = simplit(s, n, &s->blobs, &s->nblobs);
break;
diff --git a/parse/infer.c b/parse/infer.c
index 08df2d4..d8345aa 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1568,8 +1568,6 @@ static void checkrange(Inferstate *st, Node *n)
uval = n->lit.intval;
if (uval < uvranges[t->type][0] || uval > uvranges[t->type][1])
fatal(n->line, "Literal value %llu out of range for type \"%s\"", tystr(t));
- } else {
- fatal(n->line, "Literal type %s has no range\n", tystr(t));
}
}
@@ -1625,6 +1623,10 @@ static void typesub(Inferstate *st, Node *n)
case Nexpr:
settype(st, n, tyfix(st, n, type(st, n)));
typesub(st, n->expr.idx);
+ if (exprop(n) == Ocast && exprop(n->expr.args[0]) == Olit && n->expr.args[0]->expr.args[0]->lit.littype == Lint) {
+ settype(st, n->expr.args[0], exprtype(n));
+ settype(st, n->expr.args[0]->expr.args[0], exprtype(n));
+ }
for (i = 0; i < n->expr.nargs; i++)
typesub(st, n->expr.args[i]);
break;
diff --git a/test/bigliteral.myr b/test/bigliteral.myr
index 64c307d..bd310d6 100644
--- a/test/bigliteral.myr
+++ b/test/bigliteral.myr
@@ -1,5 +1,5 @@
use std
const main = {
- std.put("%l\n", 34359738368)
+ std.put("%l\n", 34359738368 castto(int64))
}