Mercurial > projects > ldc
view gen/binops.cpp @ 217:0806379a5eca trunk
[svn r233] Added: -oq command line option for writing fully qualified object names.
Added: started support for x86 80bit floating point.
Changed: aggregates passed by value now use the llvm 'byval' parameter attribute, also lays ground work for
using other attributes.
Changed: eliminated a lot more std::vectorS, these showed up pretty much at the top when profiling!
Changed: performed other misc. cleanups.
Changed: halt expression now call the new llvm trap intrinsic instead of an assert(0).
Changed: dstress suite now passes -O0 by default, this only eliminates unreferenced globals, which speeds up
linking quite a bit.
author | lindquist |
---|---|
date | Thu, 05 Jun 2008 06:38:36 +0200 |
parents | 7816aafeea3c |
children | a95056b3c996 |
line wrap: on
line source
#include "gen/llvm.h" #include "declaration.h" #include "gen/irstate.h" #include "gen/tollvm.h" #include "gen/dvalue.h" ////////////////////////////////////////////////////////////////////////////// DValue* DtoBinAdd(DValue* lhs, DValue* rhs) { LLValue* v = gIR->ir->CreateAdd(lhs->getRVal(), rhs->getRVal(), "tmp"); return new DImValue( lhs->getType(), v ); } ////////////////////////////////////////////////////////////////////////////// DValue* DtoBinSub(DValue* lhs, DValue* rhs) { LLValue* v = gIR->ir->CreateSub(lhs->getRVal(), rhs->getRVal(), "tmp"); return new DImValue( lhs->getType(), v ); } ////////////////////////////////////////////////////////////////////////////// DValue* DtoBinMul(DValue* lhs, DValue* rhs) { LLValue* v = gIR->ir->CreateMul(lhs->getRVal(), rhs->getRVal(), "tmp"); return new DImValue( lhs->getType(), v ); } ////////////////////////////////////////////////////////////////////////////// DValue* DtoBinDiv(DValue* lhs, DValue* rhs) { Type* t = lhs->getType(); llvm::Value *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFDiv(l, r, "tmp"); else if (!t->isunsigned()) res = gIR->ir->CreateSDiv(l, r, "tmp"); else res = gIR->ir->CreateUDiv(l, r, "tmp"); return new DImValue( lhs->getType(), res ); } ////////////////////////////////////////////////////////////////////////////// DValue* DtoBinRem(DValue* lhs, DValue* rhs) { Type* t = lhs->getType(); llvm::Value *l, *r; l = lhs->getRVal(); r = rhs->getRVal(); LLValue* res; if (t->isfloating()) res = gIR->ir->CreateFRem(l, r, "tmp"); else if (!t->isunsigned()) res = gIR->ir->CreateSRem(l, r, "tmp"); else res = gIR->ir->CreateURem(l, r, "tmp"); return new DImValue( lhs->getType(), res ); }