extern ir_op *get_op_Mulh(void);
-int is_direct_entity(ir_entity *ent);
-
ir_mode* ppc32_mode_Cond = NULL;
/**
/**
* Returns a singleton condition mode
*/
-ir_mode *get_ppc32_mode_Cond(void) {
+static ir_mode *get_ppc32_mode_Cond(void)
+{
if (ppc32_mode_Cond)
return ppc32_mode_Cond;
else {
ppc32_modecode mode = irm_max;
int sign = mode_is_signed(irmode);
int bits = get_mode_size_bits(irmode);
- if(mode_is_int(irmode))
+ if (mode_is_int(irmode))
{
- switch(bits)
+ switch (bits)
{
case 8:
mode = sign ? irm_Bs : irm_Bu;
break;
}
}
- else if(mode_is_float(irmode))
+ else if (mode_is_float(irmode))
{
- switch(bits)
+ switch (bits)
{
case 32:
mode = irm_F;
break;
}
}
- else if(mode_is_reference(irmode))
+ else if (mode_is_reference(irmode))
{
- switch(bits)
+ switch (bits)
{
case 32:
mode = irm_P;
* Returns true, if the given node is a Const node and it's value fits into
* a signed 16-bit variable
*/
-int is_16bit_signed_const(ir_node *node)
+static int is_16bit_signed_const(ir_node *node)
{
tarval *tv_const;
- if(!is_ppc32_Const(node)) return 0;
+ if (!is_ppc32_Const(node)) return 0;
tv_const = get_ppc32_constant_tarval(node);
- switch(get_nice_modecode(get_irn_mode(node)))
+ switch (get_nice_modecode(get_irn_mode(node)))
{
case irm_Bu:
case irm_Bs:
{
unsigned char val2 = get_tarval_sub_bits(tv_const, 2);
unsigned char val3 = get_tarval_sub_bits(tv_const, 3);
- if(val2 || val3)
+ if (val2 || val3)
return 0;
// fall through
case irm_Hu:
{
unsigned char val1 = get_tarval_sub_bits(tv_const, 1);
- if(val1&0x80)
+ if (val1&0x80)
return 0;
return 1;
}
{
unsigned char val2 = get_tarval_sub_bits(tv_const, 2);
unsigned char val3 = get_tarval_sub_bits(tv_const, 3);
- if(val2==0 && val3==0)
+ if (val2==0 && val3==0)
{
unsigned char val1 = get_tarval_sub_bits(tv_const, 1);
- if(val1&0x80)
+ if (val1&0x80)
return 0;
return 1;
}
- if(!(val2==0xff && val3==0xff))
+ if (!(val2==0xff && val3==0xff))
{
unsigned char val1 = get_tarval_sub_bits(tv_const, 1);
- if(!(val1&0x80))
+ if (!(val1&0x80))
return 0;
return 1;
}
* Returns true, if the given node is a Const node and it's value fits into
* a unsigned 16-bit variable
*/
-int is_16bit_unsigned_const(ir_node *node)
+static int is_16bit_unsigned_const(ir_node *node)
{
tarval *tv_const;
- if(!is_ppc32_Const(node)) return 0;
+ if (!is_ppc32_Const(node)) return 0;
tv_const = get_ppc32_constant_tarval(node);
- switch(get_nice_modecode(get_irn_mode(node)))
+ switch (get_nice_modecode(get_irn_mode(node)))
{
case irm_Bu:
case irm_Bs:
{
unsigned char val2 = get_tarval_sub_bits(tv_const, 2);
unsigned char val3 = get_tarval_sub_bits(tv_const, 3);
- if(val2 || val3)
+ if (val2 || val3)
return 0;
return 1;
}
* @param env The transformation environment
* @return the created ppc Add node
*/
-static ir_node *gen_Add(ppc32_transform_env_t *env) {
+static ir_node *gen_Add(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Add_left(env->irn);
ir_node *op2 = get_Add_right(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
return new_bd_ppc32_fAdd(env->dbg, env->block, op1, op2, env->mode);
case irm_F:
case irm_Bs:
case irm_Bu:
case irm_P:
- if(is_16bit_signed_const(op1))
+ if (is_16bit_signed_const(op1))
{
ir_node *addnode = new_bd_ppc32_Addi(env->dbg, env->block, op2, env->mode);
set_ppc32_constant_tarval(addnode, get_ppc32_constant_tarval(op1));
set_ppc32_offset_mode(addnode, ppc32_ao_None);
return addnode;
}
- if(is_16bit_signed_const(op2))
+ if (is_16bit_signed_const(op2))
{
ir_node *addnode = new_bd_ppc32_Addi(env->dbg, env->block, op1, env->mode);
set_ppc32_constant_tarval(addnode, get_ppc32_constant_tarval(op2));
* @param env The transformation environment
* @return the created ppc Mul node
*/
-static ir_node *gen_Mul(ppc32_transform_env_t *env) {
+static ir_node *gen_Mul(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Mul_left(env->irn);
ir_node *op2 = get_Mul_right(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
return new_bd_ppc32_fMul(env->dbg, env->block, op1, op2, env->mode);
case irm_F:
* @param env The transformation environment
* @return the created ppc Mulh node
*/
-static ir_node *gen_Mulh(ppc32_transform_env_t *env) {
+static ir_node *gen_Mulh(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_irn_n(env->irn, 0);
ir_node *op2 = get_irn_n(env->irn, 1);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_Is:
case irm_Hs:
case irm_Bs:
* @param env The transformation environment
* @return the created ppc And node
*/
-static ir_node *gen_And(ppc32_transform_env_t *env) {
+static ir_node *gen_And(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_And_left(env->irn);
ir_node *op2 = get_And_right(env->irn);
* @param env The transformation environment
* @return the created ppc Or node
*/
-static ir_node *gen_Or(ppc32_transform_env_t *env) {
+static ir_node *gen_Or(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Or_left(env->irn);
ir_node *op2 = get_Or_right(env->irn);
* @param env The transformation environment
* @return the created ppc Xor node
*/
-static ir_node *gen_Eor(ppc32_transform_env_t *env) {
+static ir_node *gen_Eor(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Eor_left(env->irn);
ir_node *op2 = get_Eor_right(env->irn);
* @param env The transformation environment
* @return the created ppc Sub node
*/
-static ir_node *gen_Sub(ppc32_transform_env_t *env) {
+static ir_node *gen_Sub(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Sub_left(env->irn);
ir_node *op2 = get_Sub_right(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
return new_bd_ppc32_fSub(env->dbg, env->block, op1, op2, env->mode);
case irm_F:
* @param env The transformation environment
* @return the created ppc fDiv node
*/
-static ir_node *gen_Quot(ppc32_transform_env_t *env) {
+static ir_node *gen_Quot(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Quot_left(env->irn);
ir_node *op2 = get_Quot_right(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
return new_bd_ppc32_fDiv(env->dbg, env->block, op1, op2, env->mode);
case irm_F:
* @param env The transformation environment
* @return the created ppc Div node
*/
-static ir_node *gen_Div(ppc32_transform_env_t *env) {
+static ir_node *gen_Div(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Div_left(env->irn);
ir_node *op2 = get_Div_right(env->irn);
- switch(get_nice_modecode(get_irn_mode(op1))){
+ switch (get_nice_modecode(get_irn_mode(op1))){
case irm_Is:
case irm_Hs:
case irm_Bs:
* @param env The transformation environment
* @return the created ppc Div node
*/
-static ir_node *gen_DivMod(ppc32_transform_env_t *env) {
+static ir_node *gen_DivMod(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_DivMod_left(env->irn);
ir_node *op2 = get_DivMod_right(env->irn);
ir_node *proj_div = NULL, *proj_mod = NULL;
{
if (is_Proj(edge->src))
{
- switch(get_Proj_proj(edge->src)){
+ switch (get_Proj_proj(edge->src)){
case pn_DivMod_res_div:
proj_div = edge->src;
break;
res_mode = get_irn_mode(proj_div);
- switch(get_nice_modecode(res_mode))
+ switch (get_nice_modecode(res_mode))
{
case irm_Is:
case irm_Hs:
}
if (proj_div == NULL)
- proj_div = new_rd_Proj(env->dbg, env->block, div_result, get_irn_mode(proj_mod), pn_DivMod_res_div);
+ proj_div = new_rd_Proj(env->dbg, div_result, get_irn_mode(proj_mod), pn_DivMod_res_div);
if (proj_mod!=NULL){
ir_node *mul_result;
* @param env The transformation environment
* @return the created ppc Mod result node
*/
-static ir_node *gen_Mod(ppc32_transform_env_t *env) {
+static ir_node *gen_Mod(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Mod_left(env->irn);
ir_node *op2 = get_Mod_right(env->irn);
ir_node *proj_div = NULL, *proj_mod = NULL;
assert(proj_mod != NULL);
res_mode = get_irn_mode(proj_mod);
- switch(get_nice_modecode(res_mode))
+ switch (get_nice_modecode(res_mode))
{
case irm_Is:
case irm_Hs:
break;
default:
- fprintf(stderr, "Mode for Mod not supported: %s\n", get_mode_name(res_mode));
- assert(0);
- return NULL;
-
+ panic("Mode for Mod not supported: %s\n", get_mode_name(res_mode));
}
- proj_div = new_rd_Proj(env->dbg, env->block, div_result, res_mode, pn_DivMod_res_div);
+ proj_div = new_rd_Proj(env->dbg, div_result, res_mode, pn_DivMod_res_div);
mul_result = new_bd_ppc32_Mullw(env->dbg, env->block, proj_div, op2, res_mode);
mod_result = new_bd_ppc32_Sub(env->dbg, env->block, op1, mul_result, res_mode);
* @param env The transformation environment
* @return the created ppc Shl node
*/
-static ir_node *gen_Shl(ppc32_transform_env_t *env) {
+static ir_node *gen_Shl(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Shl_left(env->irn);
ir_node *op2 = get_Shl_right(env->irn);
- if(is_ppc32_Const(op2))
+ if (is_ppc32_Const(op2))
{
ir_node *shift = new_bd_ppc32_Rlwinm(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
* @param env The transformation environment
* @return the created ppc Shr node
*/
-static ir_node *gen_Shr(ppc32_transform_env_t *env) {
+static ir_node *gen_Shr(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Shr_left(env->irn);
ir_node *op2 = get_Shr_right(env->irn);
- if(is_ppc32_Const(op2))
+ if (is_ppc32_Const(op2))
{
ir_node *shift = new_bd_ppc32_Rlwinm(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
* @param env The transformation environment
* @return the created ppc Sraw node
*/
-static ir_node *gen_Shrs(ppc32_transform_env_t *env) {
+static ir_node *gen_Shrs(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Shrs_left(env->irn);
ir_node *op2 = get_Shrs_right(env->irn);
- if(is_ppc32_Const(op2))
+ if (is_ppc32_Const(op2))
{
ir_node *shift = new_bd_ppc32_Srawi(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
* @param env The transformation environment
* @return the created ppc Rotl node
*/
-static ir_node *gen_Rotl(ppc32_transform_env_t *env) {
+static ir_node *gen_Rotl(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Rotl_left(env->irn);
ir_node *op2 = get_Rotl_right(env->irn);
- if(is_ppc32_Const(op2))
+ if (is_ppc32_Const(op2))
{
ir_node *rot = new_bd_ppc32_Rlwinm(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
* @param env The transformation environment
* @return the created ppc Cmp node
*/
-static ir_node *gen_Cmp(ppc32_transform_env_t *env) {
+static ir_node *gen_Cmp(ppc32_transform_env_t *env)
+{
ir_node *op1 = get_Cmp_left(env->irn);
ir_node *op2 = get_Cmp_right(env->irn);
set_irn_mode(edge->src, get_ppc32_mode_Cond());
}
- if(mode_is_float(env->mode))
+ if (mode_is_float(env->mode))
return new_bd_ppc32_fCmpu(env->dbg, env->block, op1, op2, env->mode);
- else if(mode_is_signed(env->mode))
+ else if (mode_is_signed(env->mode))
{
- if(is_16bit_signed_const(op2))
+ if (is_16bit_signed_const(op2))
{
ir_node *cmp = new_bd_ppc32_Cmpi(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
}
else
{
- if(is_16bit_unsigned_const(op2))
+ if (is_16bit_unsigned_const(op2))
{
ir_node *cmp = new_bd_ppc32_Cmpli(env->dbg, env->block, op1, env->mode);
tarval *tv_const = get_ppc32_constant_tarval(op2);
* @param env The transformation environment
* @return the created ppc Minus node
*/
-static ir_node *gen_Minus(ppc32_transform_env_t *env) {
+static ir_node *gen_Minus(ppc32_transform_env_t *env)
+{
ir_node *op = get_Minus_op(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
case irm_F:
return new_bd_ppc32_fNeg(env->dbg, env->block, op, env->mode);
* @param env The transformation environment
* @return the created ppc Not node
*/
-static ir_node *gen_Not(ppc32_transform_env_t *env) {
+static ir_node *gen_Not(ppc32_transform_env_t *env)
+{
return new_bd_ppc32_Not(env->dbg, env->block, get_Not_op(env->irn), env->mode);
}
ir_node* in[1];
set_ppc32_offset_mode(andi, ppc32_ao_Lo16);
set_ppc32_constant_tarval(andi, new_tarval_from_long(mask, mode_Is));
- in[0] = new_rd_Proj(env->dbg, env->block, andi, env->mode,1);
- be_new_Keep(&ppc32_reg_classes[CLASS_ppc32_condition], env->block, 1, in);
- return new_rd_Proj(env->dbg, env->block, andi, env->mode,0);
+ in[0] = new_rd_Proj(env->dbg, andi, env->mode,1);
+ be_new_Keep(env->block, 1, in);
+ return new_rd_Proj(env->dbg, andi, env->mode,0);
}
/**
* @param env The transformation environment
* @return the created ppc Conv node
*/
-static ir_node *gen_Conv(ppc32_transform_env_t *env) {
+static ir_node *gen_Conv(ppc32_transform_env_t *env)
+{
ir_node *op = get_Conv_op(env->irn);
ppc32_modecode from_mode=get_nice_modecode(get_irn_mode(op));
ppc32_modecode to_mode=get_nice_modecode(env->mode);
#define SKIP return op
- if(from_mode == to_mode) SKIP;
+ if (from_mode == to_mode) SKIP;
- switch(from_mode){
+ switch (from_mode){
case irm_F:
- switch(to_mode)
+ switch (to_mode)
{
case irm_D: SKIP;
default:
break;
case irm_D:
- switch(to_mode)
+ switch (to_mode)
{
case irm_F:
return new_bd_ppc32_fRsp(env->dbg, env->block, op, env->mode);
case irm_Is:
case irm_Iu:
- switch(to_mode)
+ switch (to_mode)
{
case irm_Hs:
return new_bd_ppc32_Extsh(env->dbg, env->block, op, env->mode);
case irm_Hs:
case irm_Hu:
- switch(to_mode)
+ switch (to_mode)
{
case irm_Iu:
- if(from_mode==irm_Hu)
+ if (from_mode==irm_Hu)
case irm_Hu:
return own_gen_Andi_dot_lo16(env, op, 0xffff);
case irm_Is:
case irm_Bs:
case irm_Bu:
- switch(to_mode)
+ switch (to_mode)
{
case irm_Iu:
case irm_Hu:
- if(from_mode==irm_Bs)
+ if (from_mode==irm_Bs)
case irm_Bu:
return own_gen_Andi_dot_lo16(env, op, 0xff);
case irm_Is:
}
break;
case irm_P:
- if(to_mode==irm_Is || to_mode==irm_Iu) SKIP;
+ if (to_mode==irm_Is || to_mode==irm_Iu) SKIP;
break;
default:
break;
* @param env The transformation environment
* @return the ppc node generating the absolute value
*/
-static ir_node *gen_Abs(ppc32_transform_env_t *env) {
+static ir_node *gen_Abs(ppc32_transform_env_t *env)
+{
ir_node *op = get_Abs_op(env->irn);
int shift = 7;
ir_node *n1,*n2;
- switch(get_nice_modecode(env->mode))
+ switch (get_nice_modecode(env->mode))
{
case irm_F:
case irm_D:
break;
}
panic("Mode for Abs not supported: %F", env->mode);
- return NULL;
}
/**
* @param env The transformation environment
* @return a ppc branch node
*/
-static ir_node *gen_Cond(ppc32_transform_env_t *env) {
+static ir_node *gen_Cond(ppc32_transform_env_t *env)
+{
ir_node *selector = get_Cond_selector(env->irn);
ir_mode *projmode = get_irn_mode(selector);
- if(is_Proj(selector) && projmode==get_ppc32_mode_Cond())
+ if (is_Proj(selector) && projmode==get_ppc32_mode_Cond())
{
int projnum = get_Proj_proj(selector);
ir_node *branch = new_bd_ppc32_Branch(env->dbg, env->block, selector, env->mode);
* @param env The transformation environment
* @return a ppc Unknown node
*/
-static ir_node *gen_Unknown(ppc32_transform_env_t *env) {
- if(mode_is_float(env->mode))
+static ir_node *gen_Unknown(ppc32_transform_env_t *env)
+{
+ if (mode_is_float(env->mode))
return new_bd_ppc32_fUnknown(env->dbg, env->block, env->mode);
else if (mode_is_int(env->mode))
return new_bd_ppc32_Unknown(env->dbg, env->block, env->mode);
panic("Mode %F for unknown value not supported.", env->mode);
}
-static ir_node *ldst_insert_const(ir_node *ptr, tarval **ptv, ident **pid, ppc32_transform_env_t *env) {
+static ir_node *ldst_insert_const(ir_node *ptr, tarval **ptv, ident **pid, ppc32_transform_env_t *env)
+{
tarval *tv_const = NULL;
ident *id_symconst = NULL;
- if(is_ppc32_Const(ptr))
+ if (is_ppc32_Const(ptr))
{
tv_const = get_ppc32_constant_tarval(ptr);
ptr = new_bd_ppc32_Addis_zero(env->dbg, env->block, mode_P, ppc32_ao_Ha16, tv_const, NULL);
}
- else if(is_ppc32_SymConst(ptr))
+ else if (is_ppc32_SymConst(ptr))
{
+#if 0
ir_entity *ent = get_ppc32_frame_entity(ptr);
- if(is_direct_entity(ent))
+ if (is_direct_entity(ent))
{
id_symconst = get_entity_ident(ent);
ptr = new_bd_ppc32_Addis_zero(env->dbg, env->block, mode_P, ppc32_ao_Ha16, NULL, id_symconst);
}
+#endif
}
*ptv = tv_const;
*pid = id_symconst;
* @param env The transformation environment
* @return the created ppc Load node
*/
-static ir_node *gen_Load(ppc32_transform_env_t *env) {
+static ir_node *gen_Load(ppc32_transform_env_t *env)
+{
ir_node *node = env->irn;
ir_node *loadptr = get_Load_ptr(node);
ir_node *load;
ident *id_symconst = NULL;
loadptr = ldst_insert_const(loadptr, &tv_const, &id_symconst, env);
- switch(get_nice_modecode(mode)){
+ switch (get_nice_modecode(mode)){
case irm_Bu:
load = new_bd_ppc32_Lbz(env->dbg, env->block, loadptr, get_Load_mem(node));
break;
{
ir_node *proj_load, *extsb_node;
load = new_bd_ppc32_Lbz(env->dbg, env->block, loadptr, get_Load_mem(node));
- proj_load = new_rd_Proj(env->dbg, env->block, load, mode, pn_Load_res);
+ proj_load = new_rd_Proj(env->dbg, load, mode, pn_Load_res);
extsb_node = new_bd_ppc32_Extsb(env->dbg, env->block, proj_load, mode);
exchange(get_succ_Proj(env->irn, pn_Load_res), extsb_node);
break;
panic("Mode for Load not supported: %F", env->mode);
}
- if(tv_const)
+ if (tv_const)
{
set_ppc32_offset_mode(load, ppc32_ao_Lo16);
set_ppc32_constant_tarval(load, tv_const);
}
- else if(id_symconst)
+ else if (id_symconst)
{
set_ppc32_offset_mode(load, ppc32_ao_Lo16);
set_ppc32_symconst_ident(load, id_symconst);
* @param env The transformation environment
* @return the created ppc Store node
*/
-static ir_node *gen_Store(ppc32_transform_env_t *env) {
+static ir_node *gen_Store(ppc32_transform_env_t *env)
+{
ir_node *node = env->irn;
ir_node *storeptr = get_Store_ptr(node);
ir_node *valuenode = get_Store_value(node);
storeptr = ldst_insert_const(storeptr, &tv_const, &id_symconst, env);
- switch(get_nice_modecode(mode)){
+ switch (get_nice_modecode(mode)){
case irm_Bu:
case irm_Bs:
store = new_bd_ppc32_Stb(env->dbg, env->block, storeptr, get_Store_value(node), get_Store_mem(node));
default:
panic("Mode for Store not supported: %F", env->mode);
}
- if(tv_const)
+ if (tv_const)
{
set_ppc32_offset_mode(store, ppc32_ao_Lo16);
set_ppc32_constant_tarval(store, tv_const);
}
- else if(id_symconst)
+ else if (id_symconst)
{
set_ppc32_offset_mode(store, ppc32_ao_Lo16);
set_ppc32_symconst_ident(store, id_symconst);
* @param env The transformation environment
* @return the created ppc CopyB node
*/
-static ir_node *gen_CopyB(ppc32_transform_env_t *env) {
+static ir_node *gen_CopyB(ppc32_transform_env_t *env)
+{
ir_node *mem = get_CopyB_mem(env->irn);
ir_node *src = get_CopyB_src(env->irn);
ir_node *dest = get_CopyB_dst(env->irn);
ir_node *load, *store = NULL;
- if(size/4 >= 1)
+ if (size/4 >= 1)
{
ir_node *res;
tarval *offset0 = new_tarval_from_long(0, mode_Is);
load = new_bd_ppc32_Lwz(env->dbg, env->block, src, mem);
set_ppc32_constant_tarval(load, offset0);
set_ppc32_offset_mode(load, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, load, mode_M, pn_Load_M);
- res = new_rd_Proj(env->dbg, env->block, load, mode_Is, pn_Load_res);
+ mem = new_rd_Proj(env->dbg, load, mode_M, pn_Load_M);
+ res = new_rd_Proj(env->dbg, load, mode_Is, pn_Load_res);
store = new_bd_ppc32_Stw(env->dbg, env->block, dest, res, mem);
set_ppc32_constant_tarval(store, offset0);
set_ppc32_offset_mode(store, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, store, mode_M, pn_Store_M);
+ mem = new_rd_Proj(env->dbg, store, mode_M, pn_Store_M);
- if(size/4==2)
+ if (size/4==2)
{
load = new_bd_ppc32_Lwz(env->dbg, env->block, src, mem);
set_ppc32_constant_tarval(load, offset4);
set_ppc32_offset_mode(load, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, load, mode_M, pn_Load_M);
- res = new_rd_Proj(env->dbg, env->block, load, mode_Is, pn_Load_res);
+ mem = new_rd_Proj(env->dbg, load, mode_M, pn_Load_M);
+ res = new_rd_Proj(env->dbg, load, mode_Is, pn_Load_res);
store = new_bd_ppc32_Stw(env->dbg, env->block, dest, res, mem);
set_ppc32_constant_tarval(store, offset4);
set_ppc32_offset_mode(store, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, store, mode_M, pn_Store_M);
+ mem = new_rd_Proj(env->dbg, store, mode_M, pn_Store_M);
offset = 8;
}
ir_node *ornode, *mtctrnode;
ir_node* in[3];
assert(size/4-1<=0xffff);
- if(size/4-1<0x8000)
+ if (size/4-1<0x8000)
{
ornode = new_bd_ppc32_Addi_zero(env->dbg, env->block, mode_Is);
set_ppc32_offset_mode(ornode, ppc32_ao_None);
mtctrnode = new_bd_ppc32_Mtctr(env->dbg, env->block, ornode, mode_Is);
store = new_bd_ppc32_LoopCopy(env->dbg, env->block, src, dest, mtctrnode, mem, mode_T);
- in[0] = new_rd_Proj(env->dbg, env->block, store, mode_Is, 1); // src
- in[1] = new_rd_Proj(env->dbg, env->block, store, mode_Is, 2); // dest
- in[2] = new_rd_Proj(env->dbg, env->block, store, mode_Is, 4); // temp
- be_new_Keep(&ppc32_reg_classes[CLASS_ppc32_gp], env->block, 3, in);
- in[0] = new_rd_Proj(env->dbg, env->block, store, mode_Is, 3); // ctr
- be_new_Keep(&ppc32_reg_classes[CLASS_ppc32_count], env->block, 1, in);
+ in[0] = new_rd_Proj(env->dbg, store, mode_Is, 1); // src
+ in[1] = new_rd_Proj(env->dbg, store, mode_Is, 2); // dest
+ in[2] = new_rd_Proj(env->dbg, store, mode_Is, 4); // temp
+ be_new_Keep(env->block, 3, in);
+ in[0] = new_rd_Proj(env->dbg, store, mode_Is, 3); // ctr
+ be_new_Keep(env->block, 1, in);
- mem = new_rd_Proj(env->dbg, env->block, store, mode_M, 0);
+ mem = new_rd_Proj(env->dbg, store, mode_M, 0);
offset = 4;
}
}
- if(size & 2)
+ if (size & 2)
{
ir_node *res;
tarval* offset_tarval = new_tarval_from_long(offset, mode_Is);
load = new_bd_ppc32_Lhz(env->dbg, env->block, src, mem);
set_ppc32_constant_tarval(load, offset_tarval);
set_ppc32_offset_mode(load, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, load, mode_M, pn_Load_M);
- res = new_rd_Proj(env->dbg, env->block, load, mode_Is, pn_Load_res);
+ mem = new_rd_Proj(env->dbg, load, mode_M, pn_Load_M);
+ res = new_rd_Proj(env->dbg, load, mode_Is, pn_Load_res);
store = new_bd_ppc32_Sth(env->dbg, env->block, dest, res, mem);
set_ppc32_constant_tarval(store, offset_tarval);
set_ppc32_offset_mode(store, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, store, mode_M, pn_Store_M);
+ mem = new_rd_Proj(env->dbg, store, mode_M, pn_Store_M);
offset += 2;
}
- if(size & 1)
+ if (size & 1)
{
ir_node *res;
tarval* offset_tarval = new_tarval_from_long(offset, mode_Is);
load = new_bd_ppc32_Lbz(env->dbg, env->block, src, mem);
set_ppc32_constant_tarval(load, offset_tarval);
set_ppc32_offset_mode(load, ppc32_ao_None);
- mem = new_rd_Proj(env->dbg, env->block, load, mode_M, pn_Load_M);
- res = new_rd_Proj(env->dbg, env->block, load, mode_Is, pn_Load_res);
+ mem = new_rd_Proj(env->dbg, load, mode_M, pn_Load_M);
+ res = new_rd_Proj(env->dbg, load, mode_Is, pn_Load_res);
store = new_bd_ppc32_Stb(env->dbg, env->block, dest, res, mem);
set_ppc32_constant_tarval(store, offset_tarval);
set_ppc32_offset_mode(store, ppc32_ao_None);
- // mem = new_rd_Proj(env->dbg, env->irg, env->block, store, mode_M, pn_Store_M);
+ // mem = new_rd_Proj(env->dbg, env->irg, store, mode_M, pn_Store_M);
}
return store;
*
* @param env The transformation environment
*/
-static ir_node *gen_be_FrameAddr(ppc32_transform_env_t *env) {
+static ir_node *gen_be_FrameAddr(ppc32_transform_env_t *env)
+{
ir_node *op = get_irn_n(env->irn, 0);
ir_node *add = new_bd_ppc32_Addi(env->dbg, env->block, op, mode_P);
set_ppc32_frame_entity(add, be_get_frame_entity(env->irn));
/**
* the BAD transformer.
*/
-static ir_node *bad_transform(ppc32_transform_env_t *env) {
+static ir_node *bad_transform(ppc32_transform_env_t *env)
+{
panic("Transformation not implemented: %+F\n", env->irn);
}
/**
* Enters all transform functions into the generic pointer
*/
-void ppc32_register_transformers(void) {
+void ppc32_register_transformers(void)
+{
/* first clear the generic function pointer for all ops */
clear_irp_opcodes_generic_func();
* @param node the firm node
* @param env the debug module
*/
-void ppc32_transform_node(ir_node *node, void *env) {
+void ppc32_transform_node(ir_node *node, void *env)
+{
ppc32_code_gen_t *cg = (ppc32_code_gen_t *)env;
ir_op *op = get_irn_op(node);
ir_node *asm_node = NULL;
};
/** Compares two (entity, tarval) combinations */
-static int cmp_tv_ent(const void *a, const void *b, size_t len) {
+static int cmp_tv_ent(const void *a, const void *b, size_t len)
+{
const struct tv_ent *e1 = a;
const struct tv_ent *e2 = b;
(void) len;
}
/** Generates a SymConst node for a known FP const */
-static ir_node *gen_fp_known_symconst(ppc32_transform_env_t *env, tarval *known_const) {
+static ir_node *gen_fp_known_symconst(ppc32_transform_env_t *env,
+ tarval *known_const)
+{
static set *const_set = NULL;
static ir_type *tp = NULL;
struct tv_ent key;
ir_graph *rem;
ir_entity *ent = NULL;
- if(!const_set)
+ if (!const_set)
const_set = new_set(cmp_tv_ent, 10);
- if(!tp)
- tp = new_type_primitive(new_id_from_str("const_double_t"), env->mode);
+ if (!tp)
+ tp = new_type_primitive(env->mode);
key.tv = known_const;
key.ent = NULL;
entry = set_insert(const_set, &key, sizeof(key), HASH_PTR(key.tv));
- if(!entry->ent) {
+ if (!entry->ent) {
char buf[80];
sprintf(buf, "const_%ld", get_irn_node_nr(env->irn));
ent = new_entity(get_glob_type(), new_id_from_str(buf), tp);
set_entity_ld_ident(ent, get_entity_ident(ent));
- set_entity_visibility(ent, visibility_local);
- set_entity_variability(ent, variability_constant);
- set_entity_allocation(ent, allocation_static);
+ set_entity_visibility(ent, ir_visibility_local);
+ add_entity_linkage(ent, IR_LINKAGE_CONSTANT);
/* we create a new entity here: It's initialization must resist on the
const code irg */
* @param mode node mode
* @return the created ppc Load immediate node
*/
-static ir_node *gen_ppc32_Const(ppc32_transform_env_t *env) {
+static ir_node *gen_ppc32_Const(ppc32_transform_env_t *env)
+{
tarval *tv_const = get_ppc32_constant_tarval(env->irn);
ir_node *node;
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_Hu:
{
unsigned char val1 = get_tarval_sub_bits(tv_const, 1);
- if(val1&0x80)
+ if (val1&0x80)
{
ir_node *zeroreg = new_bd_ppc32_Addi_zero(env->dbg, env->block, mode_Is);
set_ppc32_constant_tarval(zeroreg, new_tarval_from_long(0, mode_Is));
{
unsigned char val2 = get_tarval_sub_bits(tv_const,2);
unsigned char val3 = get_tarval_sub_bits(tv_const,3);
- if(!val2 && !val3)
+ if (!val2 && !val3)
{
unsigned char val1 = get_tarval_sub_bits(tv_const, 1);
- if(val1&0x80)
+ if (val1&0x80)
{
ir_node *zeroreg = new_bd_ppc32_Addi_zero(env->dbg, env->block, mode_Is);
set_ppc32_constant_tarval(zeroreg, new_tarval_from_long(0, mode_Is));
unsigned char val0 = get_tarval_sub_bits(tv_const,0);
unsigned char val1 = get_tarval_sub_bits(tv_const,1);
node = new_bd_ppc32_Addis_zero(env->dbg, env->block, env->mode, ppc32_ao_Hi16, tv_const, NULL);
- if(val0 || val1)
+ if (val0 || val1)
{
set_ppc32_constant_tarval(node, tv_const);
node = new_bd_ppc32_Ori(env->dbg, env->block, node, env->mode);
* @param mode node mode
* @return the created ppc float Load node
*/
-static ir_node *gen_ppc32_fConst(ppc32_transform_env_t *env) {
+static ir_node *gen_ppc32_fConst(ppc32_transform_env_t *env)
+{
tarval *tv_const = get_ppc32_constant_tarval(env->irn);
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_D:
case irm_F:
{
env->irn = gen_fp_known_symconst(env, tv_const);
env->mode = mode_P;
ent = get_ppc32_frame_entity(env->irn);
- if(is_direct_entity(ent))
+#if 0
+ if (is_direct_entity(ent))
{
ident *id_symconst = get_entity_ident(ent);
ir_node *node_addis = new_bd_ppc32_Addis_zero(env->dbg, env->block, env->mode, ppc32_ao_Ha16, NULL, id_symconst);
- if(mode==mode_D)
+ if (mode==mode_D)
load = new_bd_ppc32_Lfd(env->dbg, env->block, node_addis, new_NoMem());
else // mode_F
load = new_bd_ppc32_Lfs(env->dbg, env->block, node_addis, new_NoMem());
}
else
{
+#endif
addr = gen_ppc32_SymConst (env);
- if(mode==mode_D)
+ if (mode==mode_D)
load = new_bd_ppc32_Lfd(env->dbg, env->block, addr, new_NoMem());
else // mode_F
load = new_bd_ppc32_Lfs(env->dbg, env->block, addr, new_NoMem());
+#if 0
}
- return new_rd_Proj(env->dbg, env->block, load, mode, pn_Load_res);
+#endif
+ return new_rd_Proj(env->dbg, load, mode, pn_Load_res);
}
default:
}
}
-
-/**
- * Returns true, if the entity can be accessed directly,
- * or false, if the address must be loaded first
- */
-int is_direct_entity(ir_entity *ent) {
- return get_entity_visibility(ent) != visibility_external_allocated;
-/* visibility vis = get_entity_visibility(ent);
- if(is_Method_type(get_entity_type(ent)))
- {
- return (vis!=visibility_external_allocated);
- }
- else
- {
- return (vis==visibility_local);
- }*/
-}
-
/**
* Transforms a SymConst.
*
* @param mode node mode
* @return the created ppc Load immediate node
*/
-static ir_node *gen_ppc32_SymConst(ppc32_transform_env_t *env) {
+static ir_node *gen_ppc32_SymConst(ppc32_transform_env_t *env)
+{
ir_entity *ent = get_ppc32_frame_entity(env->irn);
ident *id_symconst = get_entity_ident(ent);
ir_node *node;
- switch(get_nice_modecode(env->mode)){
+ switch (get_nice_modecode(env->mode)){
case irm_P:
{
+ /*
if (is_direct_entity(ent))
{
+ */
ir_node *node_addis = new_bd_ppc32_Addis_zero(env->dbg, env->block, env->mode, ppc32_ao_Hi16, NULL, id_symconst);
node = new_bd_ppc32_Ori(env->dbg, env->block, node_addis, env->mode);
set_ppc32_symconst_ident(node, id_symconst);
set_ppc32_offset_mode(node, ppc32_ao_Lo16);
+#if 0
}
else
{
node = new_bd_ppc32_Lwz(env->dbg, env->block, node_addis, new_NoMem());
set_ppc32_symconst_ident(node, id_symconst);
set_ppc32_offset_mode(node, ppc32_ao_Lo16);
- node = new_rd_Proj(env->dbg, env->block, node, env->mode, pn_Load_res);
+ node = new_rd_Proj(env->dbg, node, env->mode, pn_Load_res);
}
+#endif
break;
}
* @param node the firm node
* @param env the debug module
*/
-void ppc32_transform_const(ir_node *node, void *env) {
+void ppc32_transform_const(ir_node *node, void *env)
+{
ppc32_code_gen_t *cgenv = (ppc32_code_gen_t *)env;
ir_node *asm_node = NULL;
ppc32_transform_env_t tenv;