diff options
| author | Hal Finkel <hfinkel@anl.gov> | 2014-08-24 03:47:06 +0000 | 
|---|---|---|
| committer | Hal Finkel <hfinkel@anl.gov> | 2014-08-24 03:47:06 +0000 | 
| commit | 6208251923e24db43261918651156b15af817d95 (patch) | |
| tree | e37b7bf96ada0c815575b2ddcea73c51a74bbf76 /clang/lib/CodeGen | |
| parent | c2b7f7a6ab63755ee366bd4b2e334e895a8fc5ab (diff) | |
| download | bcm5719-llvm-6208251923e24db43261918651156b15af817d95.tar.gz bcm5719-llvm-6208251923e24db43261918651156b15af817d95.zip  | |
Implement __builtin_signbitl for PowerPC
PowerPC uses the special PPC_FP128 type for long double on Linux, which is
composed of two 64-bit doubles. The higher-order double (which contains the
overall sign) comes first, and so the __builtin_signbitl implementation
requires special handling to extract the sign bit.
Fixes PR20691.
llvm-svn: 216341
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGBuiltin.cpp | 10 | 
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index 6734ffe3579..76e6e7c4a40 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -1347,11 +1347,17 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,      Value *Arg = EmitScalarExpr(E->getArg(0));      llvm::Type *ArgTy = Arg->getType(); -    if (ArgTy->isPPC_FP128Ty()) -      break; // FIXME: I'm not sure what the right implementation is here.      int ArgWidth = ArgTy->getPrimitiveSizeInBits();      llvm::Type *ArgIntTy = llvm::IntegerType::get(C, ArgWidth);      Value *BCArg = Builder.CreateBitCast(Arg, ArgIntTy); +    if (ArgTy->isPPC_FP128Ty()) { +      // The higher-order double comes first, and so we need to truncate the +      // pair to extract the overall sign. The order of the pair is the same +      // in both little- and big-Endian modes. +      ArgWidth >>= 1; +      ArgIntTy = llvm::IntegerType::get(C, ArgWidth); +      BCArg = Builder.CreateTrunc(BCArg, ArgIntTy); +    }      Value *ZeroCmp = llvm::Constant::getNullValue(ArgIntTy);      Value *Result = Builder.CreateICmpSLT(BCArg, ZeroCmp);      return RValue::get(Builder.CreateZExt(Result, ConvertType(E->getType())));  | 

