mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-12 06:49:02 +02:00
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
Lots of bugfixes. Added support for special foreach on strings. Added std.array, std.utf, std.ctype and std.uni to phobos. Changed all the .c files in the gen dir to .cpp (it *is* C++ after all)
This commit is contained in:
56
gen/binops.cpp
Normal file
56
gen/binops.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#include "gen/llvm.h"
|
||||
|
||||
#include "declaration.h"
|
||||
|
||||
#include "gen/irstate.h"
|
||||
#include "gen/dvalue.h"
|
||||
|
||||
DValue* DtoBinAdd(DValue* lhs, DValue* rhs)
|
||||
{
|
||||
llvm::Value* v = gIR->ir->CreateAdd(lhs->getRVal(), rhs->getRVal(), "tmp");
|
||||
return new DImValue( lhs->getType(), v );
|
||||
}
|
||||
|
||||
DValue* DtoBinSub(DValue* lhs, DValue* rhs)
|
||||
{
|
||||
llvm::Value* v = gIR->ir->CreateSub(lhs->getRVal(), rhs->getRVal(), "tmp");
|
||||
return new DImValue( lhs->getType(), v );
|
||||
}
|
||||
|
||||
DValue* DtoBinMul(DValue* lhs, DValue* rhs)
|
||||
{
|
||||
llvm::Value* 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();
|
||||
llvm::Value* 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();
|
||||
llvm::Value* 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 );
|
||||
}
|
||||
Reference in New Issue
Block a user