Name: Anonymous 2011-10-21 5:04
What software absolutely needs the x86 performance from the user and programmer perspective? Why can't we switch to ARM even if it was ~4 times slower but much cheaper?
typedef enum {
A,
B,
C,
D,
E,
F } type_tag;
struct A {
type_tag type;
...
};
struct B {
type_tag type;
...
};
struct C {
type_tag type;
...
};
struct D {
type_tag type;
...
};
struct E {
type_tag type;
...
};
struct F {
type_tag type;
...
};
typedef void (*bin_op) (type_tag*, type_tag*, void*);
// not supported
void bin_op_ns(type_tag*, type_tag*, void* ) {
assert(0);
}
static bin_op add_handlers[][] = {
// A B C D E F
{ add_A_A, add_A_B, add_A_C , bin_op_ns, bin_op_ns, add_A_F}, // A
{ add_B_A, add_B_B, add_B_C , add_B_D, bin_op_ns, bin_op_ns}, // B
{ add_C_A, add_C_B, add_C_C , bin_op_ns, bin_op_ns, bin_op_ns}, // C
{ bin_op_ns, add_D_B, bin_op_ns, add_D_D, bin_op_ns, bin_op_ns}, // D
{ bin_op_ns, bin_op_ns, bin_op_ns, bin_op_ns, add_E_E, add_E_F}, // E
{ add_F_A, bin_op_ns, bin_op_ns, bin_op_ns, add_F_E, add_F_F} }; // F
void add(type_tag* arg1, type_tag* arg2, void* ret ) {
add_handlers[*arg1][*arg2](arg1, arg2, ret);
}