mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-01-11 18:33:14 +01:00
Add support for PPC 128bit doubledouble type.
On a PowerPC target the datatype real is mapped to PPC 128bit doubledouble type. Please note that this yet does not work if you cross compile from a different architecture.
This commit is contained in:
@@ -40,6 +40,8 @@ LLType* DtoComplexBaseType(Type* t)
|
||||
case Tcomplex80:
|
||||
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
|
||||
return LLType::getX86_FP80Ty(gIR->context());
|
||||
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
|
||||
return LLType::getPPC_FP128Ty(gIR->context());
|
||||
else
|
||||
return LLType::getDoubleTy(gIR->context());
|
||||
}
|
||||
|
||||
@@ -1585,8 +1585,9 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
|
||||
fatal(); // or LLVM asserts
|
||||
}
|
||||
|
||||
llvm::Type *dtype(DtoType(T));
|
||||
char tmp[21]; // probably excessive, but covers a uint64_t
|
||||
sprintf(tmp, "%lu", static_cast<unsigned long>(gDataLayout->getTypeSizeInBits(DtoType(T))));
|
||||
sprintf(tmp, "%lu", static_cast<unsigned long>(gDataLayout->getTypeSizeInBits(dtype)));
|
||||
|
||||
// replace # in name with bitsize
|
||||
name = td->intrinsicName;
|
||||
@@ -1595,6 +1596,11 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
|
||||
size_t pos;
|
||||
while(std::string::npos != (pos = name.find(needle))) {
|
||||
if (pos > 0 && name[pos-1] == prefix) {
|
||||
// Check for special PPC128 double
|
||||
if (dtype->isPPC_FP128Ty()) {
|
||||
name.insert(pos-1, "ppc");
|
||||
pos += 3;
|
||||
}
|
||||
// Properly prefixed, insert bitwidth.
|
||||
name.replace(pos, 1, tmp);
|
||||
} else {
|
||||
|
||||
@@ -676,6 +676,11 @@ LLConstant* DtoConstFP(Type* t, longdouble value)
|
||||
bits[0] = *reinterpret_cast<uint64_t*>(&value);
|
||||
bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1);
|
||||
return LLConstantFP::get(gIR->context(), APFloat(APInt(80, 2, bits)));
|
||||
} else if(llty == LLType::getPPC_FP128Ty(gIR->context())) {
|
||||
uint64_t bits[] = {0, 0};
|
||||
bits[0] = *reinterpret_cast<uint64_t*>(&value);
|
||||
bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1);
|
||||
return LLConstantFP::get(gIR->context(), APFloat(APInt(128, 2, bits)));
|
||||
} else {
|
||||
assert(0 && "Unknown floating point type encountered");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user