symbol *currFunc;
static ast *createIval (ast *, sym_link *, initList *, ast *);
static ast *createIvalCharPtr (ast *, sym_link *, ast *);
+static ast *optimizeCompare (ast *);
ast *optimizeRRCRLC (ast *);
ast *optimizeGetHbit (ast *);
ast *backPatchLabels (ast *, symbol *, symbol *);
switch (cexpr->type)
{
case EX_VALUE:
- return (IS_AST_LIT_VALUE(cexpr));
+ if (IS_AST_LIT_VALUE(cexpr)) {
+ // this is a literal
+ return TRUE;
+ }
+ if (IS_AST_SYM_VALUE(cexpr) && IS_FUNC(AST_SYMBOL(cexpr)->type)) {
+ // a function's address will never change
+ return TRUE;
+ }
+ if (IS_AST_SYM_VALUE(cexpr) &&
+ IN_CODESPACE(SPEC_OCLS(AST_SYMBOL(cexpr)->etype))) {
+ // a symbol in code space will never change
+ // This is only for the 'char *s="hallo"' case and will have to leave
+ return TRUE;
+ }
+ return FALSE;
case EX_LINK:
werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
"unexpected link in expression tree\n");
return FALSE;
case EX_OP:
+ if (cexpr->opval.op==ARRAYINIT) {
+ fprintf (stderr, "skipping arrayinit\n");
+ // this is a list of literals
+ return TRUE;
+ }
+ if (cexpr->opval.op=='=') {
+ return constExprTree(cexpr->right);
+ }
if (cexpr->opval.op==CAST) {
// jwk: cast ignored, maybe we should throw a warning here
return constExprTree(cexpr->right);
/*-----------------------------------------------------------------*/
/* optimizeCompare - otimizes compares for bit variables */
/*-----------------------------------------------------------------*/
-ast *
+static ast *
optimizeCompare (ast * root)
{
ast *optExpr = NULL;