new UNDEF Ref

Crashing loads of uninitialized memory
proved to be a problem when implementing
unions using qbe.  This patch introduces
a new UNDEF Ref to represent data that is
known to be uninitialized.  Optimization
passes can make use of it to eliminate
some code.  In the last compilation stages,
UNDEF is treated as the constant 0xdeaddead.
This commit is contained in:
Quentin Carbonneaux 2022-12-18 17:35:19 +01:00
parent c5cd65261e
commit 5e9726946d
8 changed files with 46 additions and 28 deletions

5
all.h
View file

@ -90,10 +90,11 @@ enum {
RMem,
};
#define R (Ref){0, 0}
#define R (Ref){RTmp, 0}
#define UNDEF (Ref){RCon, 0} /* represents uninitialized data */
#define CON_Z (Ref){RCon, 1}
#define TMP(x) (Ref){RTmp, x}
#define CON(x) (Ref){RCon, x}
#define CON_Z CON(0) /* reserved zero constant */
#define SLOT(x) (Ref){RSlot, (x)&0x1fffffff}
#define TYPE(x) (Ref){RType, x}
#define CALL(x) (Ref){RCall, x}