fix alive_parser to handle fp128 constants
MODIFY
tests/unit/fp/fadd.opt
tests/unit/fp/fadd.opt
@@ -28,8 +28,7 @@ Name: fsub, type infer, constant
%t = %a
-; FIXME: timeout
-;Name: fadd, identity, two variables
-;%t = fadd half %a, %b
-; =>
-;%t = fadd half %a, %b
+Name: fadd, identity, two variables
+%t = fadd half %a, %b
+ =>
+%t = fadd half %a, %b

MODIFY
tests/unit/fp/fneg.opt
tests/unit/fp/fneg.opt
@@ -16,9 +16,8 @@ Name: fsub 0.0 => neg
%t = fneg %a
-; FIXME: timeout
-;Name: -a + 1.0 => 1.0 - a
-;%t1 = fneg half %a
-;%t = fadd half %t1, 1.0
-; =>
-;%t = fsub half 1.0, %a
+Name: -a + 1.0 => 1.0 - a
+%t1 = fneg half %a
+%t = fadd half %t1, 1.0
+ =>
+%t = fsub half 1.0, %a

MODIFY
tools/alive_lexer.h
tools/alive_lexer.h
@@ -17,7 +17,6 @@ enum token {
struct yylval_t {
union {
uint64_t num;
- double fp_num;
std::string_view str;
};
yylval_t() {}

MODIFY
tools/alive_lexer.re
tools/alive_lexer.re
@@ -116,7 +116,7 @@ space+ {
}
[-+]? [0-9]* "." [0-9]+ ([eE] [-+]? [0-9]+)? {
- yylval.fp_num = strtod((char*)YYTEXT, nullptr);
+ COPY_STR();
return FP_NUM;
}

MODIFY
tools/alive_parser.cpp
tools/alive_parser.cpp
@@ -74,8 +74,8 @@ static Value& get_constant(string_view name, Type &type) {
return *ret;
}
-static Value& get_fp_constant(double n, Type &t) {
- auto c = make_unique<FloatConst>(t, n);
+static Value& get_fp_constant(string_view n, Type &t) {
+ auto c = make_unique<FloatConst>(t, string(n));
auto ret = c.get();
fn->addConstant(move(c));
return *ret;
@@ -519,7 +519,7 @@ static Value& parse_operand(Type &type) {
case NUM:
return get_constant(yylval.num, type);
case FP_NUM:
- return get_fp_constant(yylval.fp_num, type);
+ return get_fp_constant(yylval.str, type);
case NUM_STR:
return get_num_constant(yylval.str, type);
case CSLT:

fix alive_parser to handle fp128 constants