Skip to content

Commit 2898e5c

Browse files
committedDec 30, 2012
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.
1 parent ce47e5a commit 2898e5c

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed
 

‎gen/complex.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ LLType* DtoComplexBaseType(Type* t)
4040
case Tcomplex80:
4141
if ((global.params.cpu == ARCHx86) || (global.params.cpu == ARCHx86_64))
4242
return LLType::getX86_FP80Ty(gIR->context());
43+
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
44+
return LLType::getPPC_FP128Ty(gIR->context());
4345
else
4446
return LLType::getDoubleTy(gIR->context());
4547
}

‎gen/llvmhelpers.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1585,8 +1585,9 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
15851585
fatal(); // or LLVM asserts
15861586
}
15871587

1588+
llvm::Type *dtype(DtoType(T));
15881589
char tmp[21]; // probably excessive, but covers a uint64_t
1589-
sprintf(tmp, "%lu", static_cast<unsigned long>(gDataLayout->getTypeSizeInBits(DtoType(T))));
1590+
sprintf(tmp, "%lu", static_cast<unsigned long>(gDataLayout->getTypeSizeInBits(dtype)));
15901591

15911592
// replace # in name with bitsize
15921593
name = td->intrinsicName;
@@ -1595,6 +1596,11 @@ void DtoOverloadedIntrinsicName(TemplateInstance* ti, TemplateDeclaration* td, s
15951596
size_t pos;
15961597
while(std::string::npos != (pos = name.find(needle))) {
15971598
if (pos > 0 && name[pos-1] == prefix) {
1599+
// Check for special PPC128 double
1600+
if (dtype->isPPC_FP128Ty()) {
1601+
name.insert(pos-1, "ppc");
1602+
pos += 3;
1603+
}
15981604
// Properly prefixed, insert bitwidth.
15991605
name.replace(pos, 1, tmp);
16001606
} else {

‎gen/tollvm.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,11 @@ LLConstant* DtoConstFP(Type* t, longdouble value)
676676
bits[0] = *reinterpret_cast<uint64_t*>(&value);
677677
bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1);
678678
return LLConstantFP::get(gIR->context(), APFloat(APInt(80, 2, bits)));
679+
} else if(llty == LLType::getPPC_FP128Ty(gIR->context())) {
680+
uint64_t bits[] = {0, 0};
681+
bits[0] = *reinterpret_cast<uint64_t*>(&value);
682+
bits[1] = *reinterpret_cast<uint16_t*>(reinterpret_cast<uint64_t*>(&value) + 1);
683+
return LLConstantFP::get(gIR->context(), APFloat(APInt(128, 2, bits)));
679684
} else {
680685
assert(0 && "Unknown floating point type encountered");
681686
}

‎ir/irtype.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
109109
// only x86 has 80bit float
110110
if (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
111111
return llvm::Type::getX86_FP80Ty(ctx);
112+
// PPC has a special 128bit float
113+
else if (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
114+
return llvm::Type::getPPC_FP128Ty(ctx);
112115
// other platforms use 64bit reals
113116
else
114117
return llvm::Type::getDoubleTy(ctx);
@@ -125,7 +128,9 @@ llvm::Type * IrTypeBasic::basic2llvm(Type* t)
125128
case Tcomplex80:
126129
t2 = (global.params.cpu == ARCHx86 || global.params.cpu == ARCHx86_64)
127130
? llvm::Type::getX86_FP80Ty(ctx)
128-
: llvm::Type::getDoubleTy(ctx);
131+
: (global.params.cpu == ARCHppc || global.params.cpu == ARCHppc_64)
132+
? llvm::Type::getPPC_FP128Ty(ctx)
133+
: llvm::Type::getDoubleTy(ctx);
129134
return getComplexType(ctx, t2);
130135

131136
case Tbool:

7 commit comments

Comments
 (7)

alexrp commented on Dec 30, 2012

@alexrp
Contributor

By the way, what kind of hardware are you using to do this porting work?

redstar commented on Dec 30, 2012

@redstar
MemberAuthor

A POWER7 environment with 1 CPU and 2GB memory running RHEL 6.

alexrp commented on Dec 30, 2012

@alexrp
Contributor

What kind of machine is it / where'd you get it, though? I'm looking for affordable-ish PPC hardware...

redstar commented on Dec 30, 2012

@redstar
MemberAuthor

alexrp commented on Dec 30, 2012

@alexrp
Contributor

Can you only access that service if you register as a company?

(Sorry for the off-topic, btw.)

redstar commented on Dec 30, 2012

@redstar
MemberAuthor

As far as I know: no. (Can't remember because I did my Partner World registration a long time ago.)
The registration and the service is free. Just try it.

redstar commented on Dec 30, 2012

@redstar
MemberAuthor

Otherwise this could help: http://www.polarhome.com/
I have not tried it. But could be useful for other environments like HP-UX.

Please sign in to comment.