Commit 4b21ee16 authored by Tobias Rapp's avatar Tobias Rapp
Browse files

amd64: Add creation of sign-bit tarvals to common transform module

parent 0d507efe
......@@ -39,7 +39,6 @@
#include "bearch_amd64_t.h"
#include "beirg.h"
#include "amd64_cconv.h"
#include "amd64_new_nodes.h"
#include "amd64_nodes_attr.h"
......@@ -108,3 +107,16 @@ ir_node *create_float_const(dbg_info *dbgi, ir_node *block,
return new_r_Proj(load, tv_mode, pn_amd64_xMovs_res);
}
ir_tarval *create_sign_tv(ir_mode *mode) {
assert(!mode_is_float(mode));
const char *sign_str;
if (get_mode_size_bits(mode) <= 32) {
sign_str = "0x80000000";
} else {
sign_str = "0x8000000000000000";
}
ir_tarval *tv = new_tarval_from_str(sign_str, strlen(sign_str), mode);
return tv;
}
......@@ -16,13 +16,22 @@
#include "bearch_amd64_t.h"
#include "amd64_nodes_attr.h"
/** Constructs an amd64_insn_mode_t from an ir_mode.
*/
amd64_insn_mode_t get_insn_mode_from_mode(const ir_mode *mode);
/** Creates an amd64 floating point constant from a given tarval.
*/
ir_node *create_float_const(dbg_info *dbgi, ir_node *block,
ir_tarval *tv);
/** Constructs an amd64_insn_mode_t from an ir_mode.
/** Creates a tarval with the given mode and only
* the most-significant (first) bit set.
*
* @param mode The mode of the resulting tarval, which lso decides
* between 32 and 64 bit long tarval.
*/
amd64_insn_mode_t get_insn_mode_from_mode(const ir_mode *mode);
ir_tarval *create_sign_tv(ir_mode *mode);
#endif
......@@ -1157,14 +1157,12 @@ static ir_node *gen_float_neg(ir_node *const node)
ir_node *new_op = be_transform_node(op);
ir_mode *mode = get_irn_mode(node);
const char *sign_str;
if (get_mode_size_bits(mode) == 32) {
sign_str = "0x80000000";
} else {
sign_str = "0x8000000000000000";
}
ir_tarval *tv;
if (get_mode_size_bits(mode) <= 32)
tv = create_sign_tv(mode_Iu);
else
tv = create_sign_tv(mode_Lu);
ir_tarval *tv = new_tarval_from_str(sign_str, strlen(sign_str), mode_Lu);
ir_node *load = create_float_const(dbgi, new_block, tv);
ir_node *in[] = { new_op, load };
......
......@@ -39,6 +39,7 @@
#include "amd64_finish.h"
#include "amd64_new_nodes.h"
#include "gen_amd64_regalloc_if.h"
#include "amd64_common_transform.h"
#include "amd64_transform.h"
#include "amd64_emitter.h"
#include "amd64_cconv.h"
......@@ -372,9 +373,7 @@ static ir_node *create_conv_const(ir_graph *irg, ir_mode *src_mode)
*/
static ir_node *create_sign_bit_const(ir_graph *irg)
{
const char *sign_str = "0x8000000000000000";
ir_tarval *sign_tv = new_tarval_from_str(sign_str, strlen(sign_str),
mode_Ls);
ir_tarval *sign_tv = create_sign_tv(mode_Ls);
return new_r_Const(irg, sign_tv);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment