mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
[svn r180] Fixed complex negation, and tango.math.Math now compiles.
This commit is contained in:
parent
a0c6cb6673
commit
071bf5a629
5 changed files with 31 additions and 3 deletions
|
@ -282,6 +282,24 @@ DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs)
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
DValue* DtoComplexNeg(Type* type, DValue* val)
|
||||||
|
{
|
||||||
|
val = DtoComplex(type, val);
|
||||||
|
|
||||||
|
llvm::Value *a, *b, *re, *im;
|
||||||
|
|
||||||
|
// values
|
||||||
|
DtoGetComplexParts(val, a, b);
|
||||||
|
|
||||||
|
// sub up
|
||||||
|
re = gIR->ir->CreateNeg(a, "tmp");
|
||||||
|
im = gIR->ir->CreateNeg(b, "tmp");
|
||||||
|
|
||||||
|
return new DComplexValue(type, re, im);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs)
|
llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs)
|
||||||
{
|
{
|
||||||
Type* type = lhs->getType();
|
Type* type = lhs->getType();
|
||||||
|
|
|
@ -23,6 +23,7 @@ DValue* DtoComplexAdd(Type* type, DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs);
|
DValue* DtoComplexSub(Type* type, DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs);
|
DValue* DtoComplexMul(Type* type, DValue* lhs, DValue* rhs);
|
||||||
DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs);
|
DValue* DtoComplexDiv(Type* type, DValue* lhs, DValue* rhs);
|
||||||
|
DValue* DtoComplexNeg(Type* type, DValue* val);
|
||||||
|
|
||||||
llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs);
|
llvm::Value* DtoComplexEquals(TOK op, DValue* lhs, DValue* rhs);
|
||||||
|
|
||||||
|
|
11
gen/toir.cpp
11
gen/toir.cpp
|
@ -2394,8 +2394,12 @@ DValue* NegExp::toElem(IRState* p)
|
||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
|
|
||||||
DValue* l = e1->toElem(p);
|
DValue* l = e1->toElem(p);
|
||||||
llvm::Value* val = l->getRVal();
|
|
||||||
|
|
||||||
|
if (type->iscomplex()) {
|
||||||
|
return DtoComplexNeg(type, l);
|
||||||
|
}
|
||||||
|
|
||||||
|
llvm::Value* val = l->getRVal();
|
||||||
Type* t = DtoDType(type);
|
Type* t = DtoDType(type);
|
||||||
|
|
||||||
llvm::Value* zero = 0;
|
llvm::Value* zero = 0;
|
||||||
|
@ -2407,7 +2411,10 @@ DValue* NegExp::toElem(IRState* p)
|
||||||
else if (t->ty == Tfloat64 || t->ty == Tfloat80 || t->ty == Timaginary64 || t->ty == Timaginary80)
|
else if (t->ty == Tfloat64 || t->ty == Tfloat80 || t->ty == Timaginary64 || t->ty == Timaginary80)
|
||||||
zero = llvm::ConstantFP::get(val->getType(), llvm::APFloat(0.0));
|
zero = llvm::ConstantFP::get(val->getType(), llvm::APFloat(0.0));
|
||||||
else
|
else
|
||||||
assert(0);
|
{
|
||||||
|
Logger::println("unhandled fp negation of type %s", t->toChars());
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|
|
@ -369,6 +369,8 @@ real tan(real x)
|
||||||
{
|
{
|
||||||
version (GNU) {
|
version (GNU) {
|
||||||
return tanl(x);
|
return tanl(x);
|
||||||
|
} else version (LLVMDC) {
|
||||||
|
return tango.stdc.math.tanl(x);
|
||||||
} else {
|
} else {
|
||||||
asm
|
asm
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,5 +4,5 @@ import tango.io.Stdout;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
Stdout.formatln("{} {} {}", "a", "b", 1);
|
Stdout.formatln("{} {} {}", "a", "b", 1.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue