Commit 95de248b authored by Christoph Mallon's avatar Christoph Mallon
Browse files

all: Use MAX.

parent 4b198ad8
......@@ -11,6 +11,7 @@
*/
#include <stdlib.h>
#include "../adt/util.h"
#include "callgraph.h"
#include "irloop_t.h"
......@@ -191,7 +192,7 @@ static void ana_Call(ir_node *n, void *env)
pset_insert((pset *)irg->callees, found, hash_ptr(callee));
}
unsigned depth = get_loop_depth(get_irn_loop(get_nodes_block(n)));
found->max_depth = (depth > found->max_depth) ? depth : found->max_depth;
found->max_depth = MAX(found->max_depth, depth);
}
}
}
......
......@@ -11,6 +11,7 @@
*/
#include <string.h>
#include "../adt/util.h"
#include "irouts.h"
#include "xmalloc.h"
......@@ -298,7 +299,7 @@ static void assign_tree_dom_pre_order_max(ir_node *block, void *data)
for (ir_node *p = bi->first; p; p = get_dom_info(p)->next) {
unsigned max_p = get_dom_info(p)->max_subtree_pre_num;
max = max > max_p ? max : max_p;
max = MAX(max, max_p);
has_children = true;
}
......@@ -323,7 +324,7 @@ static void assign_tree_postdom_pre_order_max(ir_node *block, void *data)
for (ir_node *p = bi->first; p; p = get_pdom_info(p)->next) {
unsigned max_p = get_pdom_info(p)->max_subtree_pre_num;
max = max > max_p ? max : max_p;
max = MAX(max, max_p);
has_children = true;
}
......
......@@ -125,7 +125,7 @@ amd64_cconv_t *amd64_decide_calling_convention(ir_type *function_type,
param->offset = stack_offset;
/* increase offset by at least AMD64_REGISTER_SIZE bytes so
* everything is aligned */
stack_offset += bits > 8 * AMD64_REGISTER_SIZE ? bits / 8 : AMD64_REGISTER_SIZE;
stack_offset += MAX(bits / 8, AMD64_REGISTER_SIZE);
continue;
}
}
......
......@@ -77,7 +77,7 @@ calling_convention_t *arm_decide_calling_convention(const ir_graph *irg,
} else {
param->offset = stack_offset;
/* increase offset 4 bytes so everything is aligned */
stack_offset += bits > 32 ? bits/8 : 4;
stack_offset += MAX(bits / 8, 4);
continue;
}
......
......@@ -254,7 +254,7 @@ static int co_get_costs_exec_freq(const ir_node *root, int pos)
int res = get_block_execfreq_int(&factors, copy_bl);
/* don't allow values smaller than one. */
return res < 1 ? 1 : res;
return MAX(1, res);
}
/**
......
......@@ -11,6 +11,7 @@
*/
#include <stdlib.h>
#include "../../adt/util.h"
#include "iredges_t.h"
#include "beirg.h"
#include "besched.h"
......@@ -420,7 +421,7 @@ static void trace_preprocess_block(trace_env_t *env, ir_node *block)
sched_timestep_t ld;
ld = latency(env, curr, 1, n, 0) + get_irn_delay(env, n);
d = ld > d ? ld : d;
d = MAX(d, ld);
}
}
}
......@@ -447,7 +448,7 @@ static void trace_node_ready(void *data, ir_node *irn, ir_node *pred)
if (pred) {
etime_p = get_irn_etime(env, pred);
etime += latency(env, pred, 1, irn, 0);
etime = etime_p > etime ? etime_p : etime;
etime = MAX(etime, etime_p);
}
set_irn_etime(env, irn, etime);
......@@ -527,8 +528,7 @@ static ir_node *muchnik_select(void *block_env, ir_nodeset_t *ready_set)
/* calculate the max delay of all candidates */
foreach_ir_nodeset(ready_set, irn, iter) {
sched_timestep_t d = get_irn_delay(env, irn);
max_delay = d > max_delay ? d : max_delay;
max_delay = MAX(max_delay, d);
}
ir_nodeset_init_size(&mcands, 8);
......
......@@ -10,6 +10,7 @@
*/
#include <time.h>
#include "../adt/util.h"
#include "irnode_t.h"
#include "irgwalk.h"
#include "irhooks.h"
......@@ -58,7 +59,7 @@ static void check_reg_pressure_class(pressure_walker_env_t *env,
be_liveness_transfer(cls, irn, &live_nodes);
cnt = ir_nodeset_size(&live_nodes);
max_live = cnt < max_live ? max_live : cnt;
max_live = MAX(max_live, cnt);
env->regpressure += cnt;
env->insn_count++;
}
......
......@@ -225,7 +225,7 @@ calling_convention_t *sparc_decide_calling_convention(ir_type *function_type,
param->type = param_type;
param->offset = stack_offset;
/* increase offset by at least SPARC_REGISTER_SIZE bytes so everything is aligned */
stack_offset += bits > 8 * SPARC_REGISTER_SIZE ? bits / 8 : SPARC_REGISTER_SIZE;
stack_offset += MAX(bits / 8, SPARC_REGISTER_SIZE);
continue;
}
......
......@@ -376,8 +376,6 @@ static instruction *decompose_mul(mul_env *env, unsigned char *R, int r, ir_tarv
return basic_decompose_mul(env, R, r, N);
}
#define IMAX(a,b) ((a) > (b) ? (a) : (b))
/**
* basic decomposition routine
*/
......@@ -387,7 +385,7 @@ static instruction *basic_decompose_mul(mul_env *env, unsigned char *R, int r, i
unsigned t;
if (R[0] == 0) { /* Case 1 */
t = R[1] > IMAX(env->max_S, R[1]);
t = R[1] > MAX(env->max_S, R[1]);
R[1] -= t;
Ns = decompose_mul(env, &R[1], r - 1, N);
return emit_LEA(env, env->root, Ns, t);
......
......@@ -246,7 +246,7 @@ static int firm_emit_indent(lc_appendable_t *app, const lc_arg_occ_t *occ,
const lc_arg_value_t *arg)
{
int i;
int width = occ->width > 0 ? occ->width : 1;
int width = MAX(1, occ->width);
int amount = arg->v_int * width;
for (i = 0; i < amount; ++i)
......
......@@ -6015,7 +6015,7 @@ static ir_node *transform_Mux_set(ir_node *n, ir_relation relation)
}
ir_graph *irg = get_irn_irg(block);
ir_node *eor = new_rd_Eor(dbgi, block, left, right, calc_mode);
unsigned shift_amount = left_low_bit > right_low_bit ? left_low_bit : right_low_bit;
unsigned shift_amount = MAX(left_low_bit, right_low_bit);
ir_node *shift_cnt = new_rd_Const_long(dbgi, irg, mode_Iu, shift_amount);
ir_node *shift = new_rd_Shr(dbgi, block, eor, shift_cnt, calc_mode);
if (calc_mode != dest_mode) {
......@@ -6435,8 +6435,7 @@ static bool sim_store_bitfield(unsigned char *buf, ir_mode *mode, long offset,
unsigned mode_size = get_mode_size_bytes(mode);
unsigned initializer_size = get_type_size_bytes(type);
for (unsigned b = offset <= 0 ? 0 : (unsigned)offset;
b < initializer_size; ++b) {
for (unsigned b = (unsigned)MAX(0, offset); b < initializer_size; ++b) {
if (b > (unsigned)offset + mode_size)
continue;
unsigned idx = be_is_big_endian() ? (initializer_size - 1 - b) : b;
......@@ -6470,7 +6469,7 @@ static bool sim_store(unsigned char *buf, ir_mode *mode, long offset,
handle_tv:
assert(get_type_mode(type) == get_tarval_mode(tv));
for (unsigned b = offset <= 0 ? 0 : (unsigned)offset;
for (unsigned b = (unsigned)MAX(0, offset);
b < initializer_size; ++b) {
if (b > (unsigned)offset + mode_size)
continue;
......@@ -6492,7 +6491,7 @@ handle_tv:
ir_type *el_type = get_array_element_type(type);
unsigned el_size = get_type_size_bytes(el_type);
assert(el_size > 0);
long offset0 = offset < 0 ? 0 : offset;
long offset0 = MAX(0, offset);
size_t first_idx = (size_t) ((unsigned)offset0 / el_size);
size_t last_idx = (size_t)
((unsigned)(offset+get_mode_size_bytes(mode)-1) / el_size);
......
......@@ -1641,7 +1641,7 @@ static void *lambda_commutative_partition(const node_t *node, environment_t *env
if (i == 0)
return pl < pr ? pl : pr;
else
return pl > pr ? pl : pr;
return MAX(pl, pr);
} else {
/* a not split out follower */
ir_node *pred = get_irn_n(irn, i);
......
......@@ -8,6 +8,8 @@
* @brief Optimization of function calls.
* @author Michael Beck
*/
#include "../adt/util.h"
#include "opt_init.h"
#include <stdbool.h>
......@@ -299,7 +301,7 @@ static mtp_additional_properties max_property(mtp_additional_properties a,
if (a == mtp_no_property || b == mtp_no_property)
return mtp_no_property;
mtp_additional_properties r = a > b ? a : b;
mtp_additional_properties r = MAX(a, b);
return r | t;
}
......
......@@ -9,6 +9,8 @@
* VanDrunen's LEPRE
* @author Michael Beck
*/
#include "../adt/util.h"
#include "irnode_t.h"
#include "irflag_t.h"
#include "array.h"
......@@ -27,7 +29,7 @@
#include "type_t.h"
/* maximum number of output Proj's */
#define MAX_PROJ ((long)pn_Load_max > (long)pn_Store_max ? (long)pn_Load_max : (long)pn_Store_max)
#define MAX_PROJ MAX((long)pn_Load_max, (long)pn_Store_max)
/**
* Mapping an address to an dense ID.
......
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