[llvm] r301105 - [APInt] Fix a few places that use APInt::getRawData to operate within the normal API.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 22 23:41:11 PDT 2017


Author: ctopper
Date: Sun Apr 23 01:41:11 2017
New Revision: 301105

URL: http://llvm.org/viewvc/llvm-project?rev=301105&view=rev
Log:
[APInt] Fix a few places that use APInt::getRawData to operate within the normal API.

getRawData exposes the internal type of the APInt class directly to its users. Ideally we wouldn't expose such an implementation detail.

This patch fixes a few of the easy cases by using truncate, extract, or a rotate.

Modified:
    llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
    llvm/trunk/lib/Target/Hexagon/HexagonMCInstLower.cpp

Modified: llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp?rev=301105&r1=301104&r2=301105&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp (original)
+++ llvm/trunk/lib/CodeGen/MIRParser/MIParser.cpp Sun Apr 23 01:41:11 2017
@@ -1949,8 +1949,7 @@ bool MIParser::getHexUint(APInt &Result)
     return true;
   StringRef V = S.substr(2);
   APInt A(V.size()*4, V, 16);
-  Result = APInt(A.getActiveBits(),
-                 ArrayRef<uint64_t>(A.getRawData(), A.getNumWords()));
+  Result = A.zextOrTrunc(A.getActiveBits());
   return false;
 }
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=301105&r1=301104&r2=301105&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Sun Apr 23 01:41:11 2017
@@ -158,9 +158,7 @@ SDValue DAGTypeLegalizer::SoftenFloatRes
   // and the low 64 bits here.
   if (DAG.getDataLayout().isBigEndian() &&
       CN->getValueType(0).getSimpleVT() == llvm::MVT::ppcf128) {
-    uint64_t words[2] = { CN->getValueAPF().bitcastToAPInt().getRawData()[1],
-                          CN->getValueAPF().bitcastToAPInt().getRawData()[0] };
-    APInt Val(128, words);
+    APInt Val = CN->getValueAPF().bitcastToAPInt().rotl(64);
     return DAG.getConstant(Val, SDLoc(CN),
                            TLI.getTypeToTransformTo(*DAG.getContext(),
                                                     CN->getValueType(0)));
@@ -1060,10 +1058,10 @@ void DAGTypeLegalizer::ExpandFloatRes_Co
   APInt C = cast<ConstantFPSDNode>(N)->getValueAPF().bitcastToAPInt();
   SDLoc dl(N);
   Lo = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
-                                 APInt(64, C.getRawData()[1])),
+                                 C.extractBits(64, 64)),
                          dl, NVT);
   Hi = DAG.getConstantFP(APFloat(DAG.EVTToAPFloatSemantics(NVT),
-                                 APInt(64, C.getRawData()[0])),
+                                 C.extractBits(64, 0)),
                          dl, NVT);
 }
 

Modified: llvm/trunk/lib/Target/Hexagon/HexagonMCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Hexagon/HexagonMCInstLower.cpp?rev=301105&r1=301104&r2=301105&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Hexagon/HexagonMCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/Hexagon/HexagonMCInstLower.cpp Sun Apr 23 01:41:11 2017
@@ -124,7 +124,7 @@ void llvm::HexagonLowerToMC(const MCInst
       // FP immediates are used only when setting GPRs, so they may be dealt
       // with like regular immediates from this point on.
       auto Expr = HexagonMCExpr::create(
-          MCConstantExpr::create(*Val.bitcastToAPInt().getRawData(),
+          MCConstantExpr::create(Val.bitcastToAPInt().getZExtValue(),
                                  AP.OutContext),
           AP.OutContext);
       HexagonMCInstrInfo::setMustExtend(*Expr, MustExtend);




More information about the llvm-commits mailing list