aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorLucas Prates <lucas.prates@arm.com>2020-06-09 09:52:01 +0100
committerLucas Prates <lucas.prates@arm.com>2020-06-18 13:17:07 +0100
commitada4c9dc4a63160b6b3cfd5965884c6cce2a405c (patch)
tree7bdfa509850df96804dab0f2b05cab5158260046 /clang/lib
parent92ad6d57c21824ddb4bca2d01734c5d2c391b5b5 (diff)
downloadllvm-ada4c9dc4a63160b6b3cfd5965884c6cce2a405c.zip
llvm-ada4c9dc4a63160b6b3cfd5965884c6cce2a405c.tar.gz
llvm-ada4c9dc4a63160b6b3cfd5965884c6cce2a405c.tar.bz2
[ARM][Clang] Removing lowering of half-precision FP arguments and returns from Clang's CodeGen
Summary: On the process of moving the argument lowering handling for half-precision floating point arguments and returns to the backend, this patch removes the code that was responsible for handling the coercion of those arguments in Clang's Codegen. Reviewers: rjmccall, chill, ostannard, dnsampaio Reviewed By: ostannard Subscribers: stuij, kristof.beyls, dmgreen, danielkiss, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D81451
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp44
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h1
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp22
3 files changed, 8 insertions, 59 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 78a0ece..8724244 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3124,20 +3124,6 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
return R;
}
-// Emit code to clear the padding bits when returning or passing as an argument
-// a 16-bit floating-point value.
-llvm::Value *CodeGenFunction::EmitCMSEClearFP16(llvm::Value *Src) {
- llvm::Type *RetTy = Src->getType();
- assert(RetTy->isFloatTy() ||
- (RetTy->isIntegerTy() && RetTy->getIntegerBitWidth() == 32));
- if (RetTy->isFloatTy()) {
- llvm::Value *T0 = Builder.CreateBitCast(Src, Builder.getIntNTy(32));
- llvm::Value *T1 = Builder.CreateAnd(T0, 0xffff, "cmse.clear");
- return Builder.CreateBitCast(T1, RetTy);
- }
- return Builder.CreateAnd(Src, 0xffff, "cmse.clear");
-}
-
void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
bool EmitRetDbgLoc,
SourceLocation EndLoc) {
@@ -3307,17 +3293,10 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
if (CurFuncDecl && CurFuncDecl->hasAttr<CmseNSEntryAttr>()) {
// For certain return types, clear padding bits, as they may reveal
// sensitive information.
- const Type *RTy = RetTy.getCanonicalType().getTypePtr();
- if (RTy->isFloat16Type() || RTy->isHalfType()) {
- // 16-bit floating-point types are passed in a 32-bit integer or float,
- // with unspecified upper bits.
- RV = EmitCMSEClearFP16(RV);
- } else {
- // Small struct/union types are passed as integers.
- auto *ITy = dyn_cast<llvm::IntegerType>(RV->getType());
- if (ITy != nullptr && isa<RecordType>(RetTy.getCanonicalType()))
- RV = EmitCMSEClearRecord(RV, ITy, RetTy);
- }
+ // Small struct/union types are passed as integers.
+ auto *ITy = dyn_cast<llvm::IntegerType>(RV->getType());
+ if (ITy != nullptr && isa<RecordType>(RetTy.getCanonicalType()))
+ RV = EmitCMSEClearRecord(RV, ITy, RetTy);
}
EmitReturnValueCheck(RV);
Ret = Builder.CreateRet(RV);
@@ -4620,17 +4599,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
if (CallInfo.isCmseNSCall()) {
// For certain parameter types, clear padding bits, as they may reveal
// sensitive information.
- const Type *PTy = I->Ty.getCanonicalType().getTypePtr();
- // 16-bit floating-point types are passed in a 32-bit integer or
- // float, with unspecified upper bits.
- if (PTy->isFloat16Type() || PTy->isHalfType()) {
- Load = EmitCMSEClearFP16(Load);
- } else {
- // Small struct/union types are passed as integer arrays.
- auto *ATy = dyn_cast<llvm::ArrayType>(Load->getType());
- if (ATy != nullptr && isa<RecordType>(I->Ty.getCanonicalType()))
- Load = EmitCMSEClearRecord(Load, ATy, I->Ty);
- }
+ // Small struct/union types are passed as integer arrays.
+ auto *ATy = dyn_cast<llvm::ArrayType>(Load->getType());
+ if (ATy != nullptr && isa<RecordType>(I->Ty.getCanonicalType()))
+ Load = EmitCMSEClearRecord(Load, ATy, I->Ty);
}
IRCallArgs[FirstIRArg] = Load;
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 935e855..4296253 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3923,7 +3923,6 @@ public:
QualType RTy);
llvm::Value *EmitCMSEClearRecord(llvm::Value *V, llvm::ArrayType *ATy,
QualType RTy);
- llvm::Value *EmitCMSEClearFP16(llvm::Value *V);
llvm::Value *EmitCommonNeonBuiltinExpr(unsigned BuiltinID,
unsigned LLVMIntrinsic,
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 564eb09..44be42aa 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -6265,17 +6265,6 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
if (isIllegalVectorType(Ty))
return coerceIllegalVector(Ty);
- // _Float16 and __fp16 get passed as if it were an int or float, but
- // with the top 16 bits unspecified. This is not done for OpenCL as it handles
- // the half type natively, and does not need to interwork with AAPCS code.
- if ((Ty->isFloat16Type() || Ty->isHalfType()) &&
- !getContext().getLangOpts().NativeHalfArgsAndReturns) {
- llvm::Type *ResType = IsAAPCS_VFP ?
- llvm::Type::getFloatTy(getVMContext()) :
- llvm::Type::getInt32Ty(getVMContext());
- return ABIArgInfo::getDirect(ResType);
- }
-
// __bf16 gets passed using the bfloat IR type, or using i32 but
// with the top 16 bits unspecified.
if (Ty->isBFloat16Type() && IsFloatABISoftFP) {
@@ -6486,17 +6475,6 @@ ABIArgInfo ARMABIInfo::classifyReturnType(QualType RetTy, bool isVariadic,
return coerceIllegalVector(RetTy);
}
- // _Float16 and __fp16 get returned as if it were an int or float, but with
- // the top 16 bits unspecified. This is not done for OpenCL as it handles the
- // half type natively, and does not need to interwork with AAPCS code.
- if ((RetTy->isFloat16Type() || RetTy->isHalfType()) &&
- !getContext().getLangOpts().NativeHalfArgsAndReturns) {
- llvm::Type *ResType = IsAAPCS_VFP ?
- llvm::Type::getFloatTy(getVMContext()) :
- llvm::Type::getInt32Ty(getVMContext());
- return ABIArgInfo::getDirect(ResType);
- }
-
// if we're using the softfp float abi, __bf16 get returned as if it were an
// int but with the top 16 bits unspecified.
if (RetTy->isBFloat16Type()) {