Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
f2ceaaa0
Commit
f2ceaaa0
authored
Apr 04, 2003
by
Michael Beck
Browse files
Fixed floting point computation, other small fixes
[r1030]
parent
50d4d093
Changes
3
Hide whitespace changes
Inline
Side-by-side
ir/tv/fltcalc.c
View file @
f2ceaaa0
...
...
@@ -26,7 +26,9 @@
********/
static
long
double
value
;
#define CAST_IN(val) (*((long double *)((val))))
#define CAST_IN(val) ({ long double xxx = *(long double *)(val); printf("CAST to %Lg\n", xxx); xxx; })
//#define CAST_IN(val) (*((long double *)((val))))
#define CAST_OUT(val) ((void *)&(val))
#define CLEAR_BUFFER() memset((char*)&value, 0, sizeof(long double))
...
...
@@ -49,6 +51,9 @@ const int fc_get_buffer_length(void)
void
fc_val_from_str
(
const
char
*
str
,
unsigned
int
len
)
{
extern
long
double
strtold
(
const
char
*
str
,
char
**
end
);
printf
(
"-> %s
\n
"
,
str
);
CLEAR_BUFFER
();
value
=
strtold
(
str
,
NULL
);
}
...
...
@@ -150,6 +155,8 @@ void fc_calc(const void *a, const void *b, int opcode)
break
;
case
FC_NEG
:
value
=
-
CAST_IN
(
a
);
printf
(
"-> NEG %Lg
\n
"
,
value
);
break
;
}
}
...
...
ir/tv/tv.c
View file @
f2ceaaa0
...
...
@@ -507,20 +507,30 @@ tarval *get_tarval_nan(ir_mode *mode)
{
ANNOUNCE
();
assert
(
mode
);
assert
(
get_mode_sort
(
mode
)
==
float_number
);
fc_get_nan
();
return
get_tarval
(
fc_get_buffer
(),
fc_get_buffer_length
(),
mode
);
if
(
get_mode_sort
(
mode
)
==
float_number
)
{
fc_get_nan
();
return
get_tarval
(
fc_get_buffer
(),
fc_get_buffer_length
(),
mode
);
}
else
{
assert
(
0
&&
"tarval is not floating point"
);
return
tarval_bad
;
}
}
tarval
*
get_tarval_inf
(
ir_mode
*
mode
)
{
ANNOUNCE
();
assert
(
mode
);
assert
(
get_mode_sort
(
mode
)
==
float_number
);
fc_get_inf
();
return
get_tarval
(
fc_get_buffer
(),
fc_get_buffer_length
(),
mode
);
if
(
get_mode_sort
(
mode
)
==
float_number
)
{
fc_get_inf
();
return
get_tarval
(
fc_get_buffer
(),
fc_get_buffer_length
(),
mode
);
}
else
{
assert
(
0
&&
"tarval is not floating point"
);
return
tarval_bad
;
}
}
/*
...
...
@@ -545,6 +555,7 @@ int tarval_is_negative(tarval *a)
default:
assert
(
0
&&
"not implemented"
);
return
0
;
}
}
...
...
@@ -652,6 +663,7 @@ tarval *tarval_neg(tarval *a) /* negation */
assert
(
mode_is_num
(
a
->
mode
));
/* negation only for numerical values */
assert
(
mode_is_signed
(
a
->
mode
));
/* negation is difficult without negative numbers, isn't it */
printf
(
"NEG
\n
"
);
switch
(
get_mode_sort
(
a
->
mode
))
{
case
int_number
:
...
...
@@ -659,6 +671,7 @@ tarval *tarval_neg(tarval *a) /* negation */
return
get_tarval
(
sc_get_buffer
(),
sc_get_buffer_length
(),
a
->
mode
);
case
float_number
:
printf
(
"FP NEG
\n
"
);
fc_neg
(
a
->
value
);
return
get_tarval
(
fc_get_buffer
(),
fc_get_buffer_length
(),
a
->
mode
);
...
...
ir/tv/tv.h
View file @
f2ceaaa0
...
...
@@ -510,8 +510,8 @@ char *tarval_sub_bitpattern(tarval *tv, int from, int to);
* Because this is the bit representation of the target machine, only the following
* operations are legal on the result:
*
* - concatenation (
be aware of the endieness
)
* - bitwise logical operations to selct/mask bits
* - concatenation (
endian dependance MUST be handled by the CALLER
)
* - bitwise logical operations to sel
e
ct/mask bits
*
* @param tv the tarval
* @param byte_ofs the byte offset
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment