let's see if the c implementation can handle the ternary operator!
This commit is contained in:
parent
453cd8af9c
commit
aeb00e1b8d
2 changed files with 29 additions and 29 deletions
54
main.c
54
main.c
|
|
@ -478,12 +478,6 @@ void calculate_simplifications(void)
|
|||
}
|
||||
|
||||
if (use_operators.ternary)
|
||||
{
|
||||
assert(!"TODO");
|
||||
}
|
||||
|
||||
// consider ternary:
|
||||
#if 0
|
||||
{
|
||||
for (int i = 0; i < N; i++)
|
||||
{
|
||||
|
|
@ -493,35 +487,39 @@ void calculate_simplifications(void)
|
|||
{
|
||||
if (costs[j] != INT_MAX)
|
||||
{
|
||||
uint16_t ternary_truthtable =
|
||||
(truthtable & i) | (~truthtable & j);
|
||||
|
||||
int ternary_cost = 1 + cost + costs[i] + costs[j];
|
||||
|
||||
if (ternary_cost < costs[ternary_truthtable])
|
||||
{
|
||||
if (reverse[ternary_truthtable] == -1)
|
||||
{
|
||||
// add it:
|
||||
append(ternary_truthtable, ternary_cost);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update it:
|
||||
update(ternary_truthtable, ternary_cost);
|
||||
}
|
||||
|
||||
lookup[ternary_truthtable].kind = ek_ternary;
|
||||
lookup[ternary_truthtable].cond = truthtable;
|
||||
lookup[ternary_truthtable].left = i;
|
||||
lookup[ternary_truthtable].right = j;
|
||||
}
|
||||
#define TERNARY(C, T, F) \
|
||||
{ \
|
||||
uint16_t ternary_truthtable = \
|
||||
((C) & (T)) | (~(C) & (F)); \
|
||||
\
|
||||
if (ternary_cost < costs[ternary_truthtable]) \
|
||||
{ \
|
||||
if (reverse[ternary_truthtable] == -1) \
|
||||
{ \
|
||||
append(ternary_truthtable, ternary_cost); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
update(ternary_truthtable, ternary_cost); \
|
||||
} \
|
||||
\
|
||||
lookup[ternary_truthtable].kind = ek_ternary; \
|
||||
lookup[ternary_truthtable].cond = (C); \
|
||||
lookup[ternary_truthtable].left = (T); \
|
||||
lookup[ternary_truthtable].right = (F); \
|
||||
} \
|
||||
} \
|
||||
|
||||
TERNARY(truthtable, i, j);
|
||||
TERNARY(i, truthtable, j);
|
||||
TERNARY(i, j, truthtable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
4
makefile
4
makefile
|
|
@ -9,7 +9,9 @@ cppflags = -D _GNU_SOURCE
|
|||
|
||||
cflags = -Werror -Wall -Wextra -Wstrict-prototypes
|
||||
|
||||
cflags += -Wno-unused
|
||||
cflags += -O3
|
||||
|
||||
# cflags += -Wno-unused
|
||||
|
||||
ldflags += -lreadline
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue