diff dmd/expression.h @ 1151:3cf0066e6faf

- Versioned Expresssion::toElem with #if IN_DMD/IN_LLVM. - Eliminated the DLRValue DValue. - Implemented proactive handling of l-value CastExpS. - Minor tweak in runtime memory.d .
author Tomas Lindquist Olsen <tomas.l.olsen gmail.com>
date Sat, 28 Mar 2009 05:00:43 +0100
parents 1860414bf3b7
children 521dd1626d76
line wrap: on
line diff
--- a/dmd/expression.h	Fri Mar 27 23:24:47 2009 +0100
+++ b/dmd/expression.h	Sat Mar 28 05:00:43 2009 +0100
@@ -46,10 +46,10 @@
 
 enum TOK;
 
+#if IN_DMD
 // Back end
 struct IRState;
 
-#if IN_DMD
 struct dt_t;
 struct elem;
 struct Symbol;		// back end symbol
@@ -60,11 +60,9 @@
 #endif
 
 #if IN_LLVM
+struct IRState;
 struct DValue;
-typedef DValue elem;
-
-namespace llvm
-{
+namespace llvm {
     class Constant;
     class ConstantInt;
 }
@@ -160,13 +158,18 @@
     virtual void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
     virtual Expression *buildArrayLoop(Arguments *fparams);
 
+#if IN_DMD
     // Back end
     virtual elem *toElem(IRState *irs);
-#if IN_DMD
     virtual dt_t **toDt(dt_t **pdt);
-#elif IN_LLVM
-    // LDC
+#endif
+
+#if IN_LLVM
+    virtual DValue* toElem(IRState* irs);
     virtual llvm::Constant *toConstElem(IRState *irs);
+    virtual void cacheLvalue(IRState* irs);
+
+    llvm::Value* cachedLvalue;
 #endif
 };
 
@@ -191,12 +194,12 @@
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
     Expression *toLvalue(Scope *sc, Expression *e);
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -219,12 +222,12 @@
     int isBool(int result);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -250,12 +253,12 @@
 #ifdef _DH
     OutBuffer hexp;
 #endif
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -305,7 +308,13 @@
     Expression *doInline(InlineDoState *ids);
     //Expression *inlineScan(InlineScanState *iss);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct SuperExp : ThisExp
@@ -332,12 +341,12 @@
     MATCH implicitConvTo(Type *t);
     Expression *castTo(Scope *sc, Type *t);
     Expression *interpret(InterState *istate);
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -365,12 +374,12 @@
     unsigned charAt(size_t i);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -392,11 +401,17 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     Expression *castTo(Scope *sc, Type *t);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct ArrayLiteralExp : Expression
@@ -409,7 +424,6 @@
     Expression *syntaxCopy();
     Expression *semantic(Scope *sc);
     int isBool(int result);
-    elem *toElem(IRState *irs);
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
@@ -418,16 +432,18 @@
     Expression *interpret(InterState *istate);
     MATCH implicitConvTo(Type *t);
     Expression *castTo(Scope *sc, Type *t);
-#if IN_DMD
-    dt_t **toDt(dt_t **pdt);
-#elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
-#endif
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
+
+#if IN_DMD
+    elem *toElem(IRState *irs);
+    dt_t **toDt(dt_t **pdt);
+#elif IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 struct AssocArrayLiteralExp : Expression
@@ -440,7 +456,9 @@
     Expression *syntaxCopy();
     Expression *semantic(Scope *sc);
     int isBool(int result);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
@@ -453,9 +471,10 @@
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
+
 #if IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
 #endif
 };
 
@@ -477,25 +496,25 @@
     Expression *semantic(Scope *sc);
     Expression *getField(Type *type, unsigned offset);
     int getFieldIndex(Type *type, unsigned offset);
-    elem *toElem(IRState *irs);
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void toMangleBuffer(OutBuffer *buf);
     void scanForNestedRef(Scope *sc);
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
-#if IN_DMD
-    dt_t **toDt(dt_t **pdt);
-#elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
-#endif
     Expression *toLvalue(Scope *sc, Expression *e);
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
-    
+
+#if IN_DMD
+    elem *toElem(IRState *irs);
+    dt_t **toDt(dt_t **pdt);
+#elif IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 struct TypeDotIdExp : Expression
@@ -506,7 +525,13 @@
     Expression *syntaxCopy();
     Expression *semantic(Scope *sc);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct TypeExp : Expression
@@ -516,7 +541,13 @@
     Expression *semantic(Scope *sc);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     Expression *optimize(int result);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct ScopeExp : Expression
@@ -526,8 +557,14 @@
     ScopeExp(Loc loc, ScopeDsymbol *sds);
     Expression *syntaxCopy();
     Expression *semantic(Scope *sc);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct TemplateExp : Expression
@@ -556,7 +593,9 @@
 	Type *newtype, Expressions *arguments);
     Expression *syntaxCopy();
     Expression *semantic(Scope *sc);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void scanForNestedRef(Scope *sc);
@@ -564,6 +603,10 @@
     //int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     //Expression *inlineScan(InlineScanState *iss);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct NewAnonClassExp : Expression
@@ -601,10 +644,14 @@
     Expression *castTo(Scope *sc, Type *t);
     void scanForNestedRef(Scope *sc);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
 #endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 // Variable
@@ -624,18 +671,21 @@
     void checkEscape();
     Expression *toLvalue(Scope *sc, Expression *e);
     Expression *modifiableLvalue(Scope *sc, Expression *e);
+#if IN_DMD
     elem *toElem(IRState *irs);
-#if IN_DMD
     dt_t **toDt(dt_t **pdt);
-#elif IN_LLVM
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
 #endif
     void scanForNestedRef(Scope *sc);
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     //Expression *inlineScan(InlineScanState *iss);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+    void cacheLvalue(IRState* irs);
+#endif
 };
 
 #if DMDV2
@@ -663,14 +713,18 @@
     void scanForNestedRef(Scope *sc);
     char *toChars();
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
 
     int inlineCost(InlineCostState *ics);
     //Expression *doInline(InlineDoState *ids);
     //Expression *inlineScan(InlineScanState *iss);
 
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 // Declaration of a symbol
@@ -685,12 +739,18 @@
     Expression *interpret(InterState *istate);
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     void scanForNestedRef(Scope *sc);
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct TypeidExp : Expression
@@ -723,7 +783,13 @@
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     int checkSideEffect(int flag);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct IsExp : Expression
@@ -796,7 +862,9 @@
 
     Expression *op_overload(Scope *sc);
 
+#if IN_DMD
     elem *toElemBin(IRState *irs, int op);
+#endif
 };
 
 struct BinAssignExp : BinExp
@@ -836,7 +904,13 @@
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct DotIdExp : UnaExp
@@ -869,7 +943,14 @@
     Expression *interpret(InterState *istate);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void dump(int indent);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    void cacheLvalue(IRState* irs);
+#endif
 };
 
 struct DotTemplateInstanceExp : UnaExp
@@ -895,7 +976,13 @@
     void dump(int indent);
 
     int inlineCost(InlineCostState *ics);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct DotTypeExp : UnaExp
@@ -905,7 +992,13 @@
     DotTypeExp(Loc loc, Expression *e, Dsymbol *sym);
     Expression *semantic(Scope *sc);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct CallExp : UnaExp
@@ -924,25 +1017,36 @@
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     void dump(int indent);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     void scanForNestedRef(Scope *sc);
     Expression *toLvalue(Scope *sc, Expression *e);
 
     int inlineCost(InlineCostState *ics);
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct AddrExp : UnaExp
 {
     AddrExp(Loc loc, Expression *e);
     Expression *semantic(Scope *sc);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     MATCH implicitConvTo(Type *t);
     Expression *castTo(Scope *sc, Type *t);
     Expression *optimize(int result);
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 struct PtrExp : UnaExp
@@ -952,9 +1056,16 @@
     Expression *semantic(Scope *sc);
     Expression *toLvalue(Scope *sc, Expression *e);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    void cacheLvalue(IRState* irs);
+#endif
 };
 
 struct NegExp : UnaExp
@@ -969,7 +1080,13 @@
     // For operator overloading
     Identifier *opId();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct UAddExp : UnaExp
@@ -993,7 +1110,13 @@
     // For operator overloading
     Identifier *opId();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct NotExp : UnaExp
@@ -1003,7 +1126,13 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     int isBit();
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct BoolExp : UnaExp
@@ -1013,7 +1142,13 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     int isBit();
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct DeleteExp : UnaExp
@@ -1023,7 +1158,13 @@
     Expression *checkToBoolean();
     int checkSideEffect(int flag);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct CastExp : UnaExp
@@ -1039,13 +1180,17 @@
     int checkSideEffect(int flag);
     void checkEscape();
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
 
     // For operator overloading
     Identifier *opId();
 
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 
@@ -1065,7 +1210,9 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     void dump(int indent);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
     void scanForNestedRef(Scope *sc);
     void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
     Expression *buildArrayLoop(Arguments *fparams);
@@ -1074,8 +1221,10 @@
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
 
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 struct ArrayLengthExp : UnaExp
@@ -1085,7 +1234,13 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 // e1[a0,a1,a2,a3,...]
@@ -1128,7 +1283,13 @@
     int checkSideEffect(int flag);
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct IndexExp : BinExp
@@ -1146,9 +1307,13 @@
     Expression *doInline(InlineDoState *ids);
     void scanForNestedRef(Scope *sc);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
-    // LDC
-    virtual llvm::Constant *toConstElem(IRState *irs);
+#elif IN_LLVM
+    DValue* toElem(IRState* irs);
+    llvm::Constant *toConstElem(IRState *irs);
+    void cacheLvalue(IRState* irs);
+#endif
 };
 
 /* For both i++ and i--
@@ -1160,7 +1325,13 @@
     Expression *interpret(InterState *istate);
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     Identifier *opId();    // For operator overloading
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct AssignExp : BinExp
@@ -1173,9 +1344,23 @@
     Identifier *opId();    // For operator overloading
     void buildArrayIdent(OutBuffer *buf, Expressions *arguments);
     Expression *buildArrayLoop(Arguments *fparams);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
+#if IN_DMD
+#define ASSIGNEXP_TOELEM    elem *toElem(IRState *irs);
+#elif IN_LLVM
+#define ASSIGNEXP_TOELEM    DValue* toElem(IRState *irs);
+#else
+#define ASSIGNEXP_TOELEM
+#endif
+
 #define ASSIGNEXP(op)	\
 struct op##AssignExp : BinExp					\
 {								\
@@ -1187,7 +1372,7 @@
 								\
     Identifier *opId();    /* For operator overloading */	\
 								\
-    elem *toElem(IRState *irs);					\
+    ASSIGNEXP_TOELEM					        \
 };
 
 #define X(a) a
@@ -1210,6 +1395,7 @@
 
 #undef X
 #undef ASSIGNEXP
+#undef ASSIGNEXP_TOELEM
 
 struct AddExp : BinExp
 {
@@ -1225,7 +1411,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct MinExp : BinExp
@@ -1241,7 +1433,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct CatExp : BinExp
@@ -1255,7 +1453,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct MulExp : BinExp
@@ -1272,7 +1476,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct DivExp : BinExp
@@ -1288,7 +1498,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct ModExp : BinExp
@@ -1304,7 +1520,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct ShlExp : BinExp
@@ -1318,7 +1540,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct ShrExp : BinExp
@@ -1332,7 +1560,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct UshrExp : BinExp
@@ -1346,7 +1580,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct AndExp : BinExp
@@ -1363,7 +1603,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct OrExp : BinExp
@@ -1380,7 +1626,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct XorExp : BinExp
@@ -1397,7 +1649,13 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct OrOrExp : BinExp
@@ -1409,7 +1667,13 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     int checkSideEffect(int flag);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct AndAndExp : BinExp
@@ -1421,7 +1685,13 @@
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
     int checkSideEffect(int flag);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct CmpExp : BinExp
@@ -1436,7 +1706,13 @@
     int isCommutative();
     Identifier *opId();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct InExp : BinExp
@@ -1449,13 +1725,25 @@
     Identifier *opId();
     Identifier *opId_r();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 struct RemoveExp : BinExp
 {
     RemoveExp(Loc loc, Expression *e1, Expression *e2);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 // == and !=
@@ -1472,7 +1760,13 @@
     int isCommutative();
     Identifier *opId();
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 // === and !===
@@ -1484,7 +1778,13 @@
     int isBit();
     Expression *optimize(int result);
     Expression *interpret(InterState *istate);
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 /****************************************************************/
@@ -1512,7 +1812,13 @@
     Expression *doInline(InlineDoState *ids);
     Expression *inlineScan(InlineScanState *iss);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#endif
+
+#if IN_LLVM
+    DValue* toElem(IRState* irs);
+#endif
 };
 
 #if DMDV2
@@ -1557,8 +1863,12 @@
     void toCBuffer(OutBuffer *buf, HdrGenState *hgs);
     Expression *toLvalue(Scope *sc, Expression *e);
 
+#if IN_DMD
     elem *toElem(IRState *irs);
+#elif IN_LLVM
+    DValue* toElem(IRState* irs);
     llvm::Constant *toConstElem(IRState *irs);
+#endif
 };
 
 #endif