-/* The codegenerator (transform FIRM Conv nodes into ppc FIRM) */
-/* $Id$ */
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
-#ifdef HAVE_CONFIG_H
+/**
+ * @file
+ * @brief The codegenerator (transform FIRM Conv nodes into ppc FIRM)
+ * @author Moritz Kroll, Jens Mueller
+ * @version $Id$
+ */
#include "config.h"
-#endif
#include "irnode_t.h"
#include "irgraph_t.h"
#include "iredges_t.h"
#include "irvrfy.h"
#include "ircons.h"
-#include "dbginfo.h"
#include "iropt_t.h"
#include "debug.h"
+#include "error.h"
-#include "../benode_t.h"
+#include "../benode.h"
#include "bearch_ppc32_t.h"
#include "ppc32_nodes_attr.h"
-//#include "../arch/archop.h" /* we need this for Min and Max nodes */
#include "ppc32_transform_conv.h"
+#include "ppc32_transform.h"
#include "ppc32_new_nodes.h"
#include "ppc32_map_regs.h"
ir_node *current_block;
int conv_nodes_found;
-entity *memslot;
+ir_entity *memslot;
ir_node *memory;
/**
ir_mode *from_mode, ir_mode *to_mode)
{
ir_type *method_type;
- entity *method_ent;
+ ir_entity *method_ent;
ir_node *in[1];
ir_node *call, *callee, *call_results;
in[0] = op;
- method_type = new_type_method(new_id_from_str("convert_call_type"), 1, 1);
- set_method_param_type(method_type, 0, new_type_primitive(new_id_from_str("conv_param"), from_mode));
- set_method_res_type(method_type, 0, new_type_primitive(new_id_from_str("conv_result"), to_mode));
+ method_type = new_type_method(1, 1);
+ set_method_param_type(method_type, 0, new_type_primitive(from_mode));
+ set_method_res_type(method_type, 0, new_type_primitive(to_mode));
method_ent = new_entity(get_glob_type(), new_id_from_str(funcname), method_type);
- callee = new_rd_SymConst_addr_ent(env->dbg, env->irg, method_ent, method_type);
- call = new_rd_Call(env->dbg, env->irg, env->block, memory, callee, 1, in, method_type);
- call_results = new_rd_Proj(env->dbg, env->irg, env->block, call, mode_T, pn_Call_T_result);
- memory = new_rd_Proj(env->dbg, env->irg, env->block, call, mode_M, pn_Call_M_regular);
+ callee = new_rd_SymConst_addr_ent(env->dbg, env->irg, mode_P_code, method_ent, method_type);
+ call = new_rd_Call(env->dbg, env->block, memory, callee, 1, in, method_type);
+ call_results = new_rd_Proj(env->dbg, env->block, call, mode_T, pn_Call_T_result);
+ memory = new_rd_Proj(env->dbg, env->block, call, mode_M, pn_Call_M);
- return new_rd_Proj(env->dbg, env->irg, env->block, call_results, to_mode, 0);
+ return new_rd_Proj(env->dbg, env->block, call_results, to_mode, 0);
}
/**
static ir_node *gen_Conv(ppc32_transform_env_t *env, ir_node *op) {
ir_mode *from_mode = get_irn_mode(get_irn_n(env->irn,0));
ir_mode *to_mode = env->mode;
- modecode from_modecode=get_mode_modecode(from_mode);
- modecode to_modecode=get_mode_modecode(to_mode);
+ ppc32_modecode from_modecode=get_nice_modecode(from_mode);
+ ppc32_modecode to_modecode=get_nice_modecode(to_mode);
switch(from_modecode){
case irm_F:
- op = new_rd_Conv(env->dbg, env->irg, env->block, op, mode_D);
+ op = new_rd_Conv(env->dbg, env->block, op, mode_D);
// fall through
case irm_D:
{
ir_node *res;
if (mode_is_signed(to_mode)) // Float to integer
{
- ir_node *fctiw = new_rd_ppc32_fCtiw(env->dbg, env->irg, env->block, op, from_mode);
- ir_node *stfd = new_rd_ppc32_Stfd(env->dbg, env->irg, env->block, get_irg_frame(env->irg),
- fctiw, memory, mode_T);
- ir_node *storememproj = new_rd_Proj(env->dbg, env->irg, env->block, stfd, mode_M, pn_Store_M);
- ir_node *lwz = new_rd_ppc32_Lwz(env->dbg, env->irg, env->block, get_irg_frame(env->irg),
- storememproj, mode_T);
+ ir_node *fctiw = new_bd_ppc32_fCtiw(env->dbg, env->block, op, from_mode);
+ ir_node *stfd = new_bd_ppc32_Stfd(env->dbg, env->block, get_irg_frame(env->irg),
+ fctiw, memory);
+ ir_node *storememproj = new_rd_Proj(env->dbg, env->block, stfd, mode_M, pn_Store_M);
+ ir_node *lwz = new_bd_ppc32_Lwz(env->dbg, env->block, get_irg_frame(env->irg),
+ storememproj);
set_ppc32_frame_entity(stfd, memslot);
set_ppc32_offset_mode(stfd, ppc32_ao_Lo16); // TODO: only allows a 16-bit offset on stack
set_ppc32_frame_entity(lwz, memslot);
set_ppc32_offset_mode(stfd, ppc32_ao_Lo16); // TODO: only allows a 16-bit offset on stack
- memory = new_rd_Proj(env->dbg, env->irg, env->block, lwz, mode_M, pn_Store_M);
- res = new_rd_Proj(env->dbg, env->irg, env->block, lwz, to_mode, pn_Load_res);
+ memory = new_rd_Proj(env->dbg, env->block, lwz, mode_M, pn_Store_M);
+ res = new_rd_Proj(env->dbg, env->block, lwz, to_mode, pn_Load_res);
}
else
case irm_Hs:
case irm_Bu:
case irm_Hu:
- return new_rd_Conv(env->dbg, env->irg, env->block, res, to_mode);
+ return new_rd_Conv(env->dbg, env->block, res, to_mode);
case irm_Is:
case irm_Iu:
return res;
}
case irm_Hs:
case irm_Bs:
- op = new_rd_Conv(env->dbg, env->irg, env->block, op, mode_Is);
+ op = new_rd_Conv(env->dbg, env->block, op, mode_Is);
case irm_Is:
return own_gen_convert_call(env, op, (to_mode == mode_D) ? "conv_int_to_double" : "conv_int_to_single", mode_Is, to_mode);
case irm_Hu:
case irm_Bu:
- op = new_rd_Conv(env->dbg, env->irg, env->block, op, mode_Iu);
+ op = new_rd_Conv(env->dbg, env->block, op, mode_Iu);
case irm_Iu:
return own_gen_convert_call(env, op, (to_mode == mode_D) ? "conv_unsigned_int_to_double": "conv_unsigned_int_to_single", mode_Iu, to_mode);
default:
break;
}
- fprintf(stderr, "Mode for Conv not supported: %s -> %s\n", get_mode_name(from_mode), get_mode_name(to_mode));
- assert(0);
- return 0;
-
- // return op;
+ panic("Mode for Conv not supported: %F -> %F", from_mode, to_mode);
}
int search_from_node_in_block(ir_node *from, ir_node *to)
memslot = frame_alloc_area(frame_type, get_mode_size_bytes(mode_D), 4, 0);
}
- attr->convs = xmalloc(attr->conv_count * sizeof(ir_node *));
+ attr->convs = XMALLOCN(ir_node*, attr->conv_count);
for (i = 0, current_conv = attr->first_conv; i < attr->conv_count; i++, current_conv = current_conv->link)
{
tenv.block = current_block;
tenv.irg = current_ir_graph;
- tenv.mod = cgenv->mod;
+ DEBUG_ONLY(tenv.mod = cgenv->mod;)
memory = get_irg_no_mem(current_ir_graph);
for(i = 0; i < attr->conv_count; i++)
void init_block(void)
{
- cw_block_attr *attr = xmalloc(sizeof(cw_block_attr));
+ cw_block_attr *attr = XMALLOC(cw_block_attr);
attr->first_conv = NULL;
attr->convs = NULL; /* attr->convs is set in finalize_block() */
attr->conv_count = 0;
* Constant generating code
*/
+#if 0
struct tv_ent {
- entity *ent;
+ ir_entity *ent;
tarval *tv;
};
struct tv_ent *entry;
ir_node *cnst;
ir_graph *rem;
- entity *ent;
+ ir_entity *ent;
if(!const_set)
const_set = new_set(cmp_tv_ent, 10);
return new_rd_SymConst_addr_ent(env->dbg, env->irg, ent, tp);
}
+#endif
/**
* Transforms a Const
ir_node *constant;
if (mode_is_float(env->mode))
- constant = new_rd_ppc32_fConst(env->dbg, env->irg, env->block, env->mode);
+ constant = new_bd_ppc32_fConst(env->dbg, env->block, env->mode);
else
- constant = new_rd_ppc32_Const(env->dbg, env->irg, env->block, env->mode);
+ constant = new_bd_ppc32_Const(env->dbg, env->block, env->mode);
set_ppc32_constant_tarval(constant, tv_const);
return constant;
}
*/
static ir_node *gen_SymConst(ppc32_transform_env_t *env) {
ir_node *symconst;
- symconst = new_rd_ppc32_SymConst(env->dbg, env->irg, env->block, env->mode);
+ symconst = new_bd_ppc32_SymConst(env->dbg, env->block, env->mode);
set_ppc32_frame_entity(symconst, get_SymConst_entity(env->irn));
return symconst;
}
*/
void ppc32_conv_walk(ir_node *node, void *env) {
ppc32_code_gen_t *cgenv = (ppc32_code_gen_t *)env;
- opcode code = get_irn_opcode(node);
+ ir_opcode code = get_irn_opcode(node);
ppc32_transform_env_t tenv;
if (is_Block(node))
}
tenv.irg = current_ir_graph;
- tenv.mod = cgenv->mod;
+ DEBUG_ONLY(tenv.mod = cgenv->mod;)
if (code == iro_Conv)
{
- modecode from_mode=get_mode_modecode(get_irn_mode(get_irn_n(node,0)));
- modecode to_mode=get_mode_modecode(get_irn_mode(node));
+ ppc32_modecode from_mode=get_nice_modecode(get_irn_mode(get_irn_n(node,0)));
+ ppc32_modecode to_mode=get_nice_modecode(get_irn_mode(node));
cw_block_attr *attr;
if(from_mode == to_mode) return;
*/
void ppc32_pretransform_walk(ir_node *node, void *env) {
ppc32_code_gen_t *cgenv = (ppc32_code_gen_t *)env;
- opcode code = get_irn_opcode(node);
+ ir_opcode code = get_irn_opcode(node);
ppc32_transform_env_t tenv;
if (is_Block(node))
}
tenv.irg = current_ir_graph;
- tenv.mod = cgenv->mod;
+ DEBUG_ONLY(tenv.mod = cgenv->mod;)
if(code == iro_Const || code == iro_SymConst)
{