]> granicus.if.org Git - llvm/commitdiff
[ARM] GlobalISel: Use Subtarget in Legalizer
authorDiana Picus <diana.picus@linaro.org>
Fri, 17 Feb 2017 11:25:17 +0000 (11:25 +0000)
committerDiana Picus <diana.picus@linaro.org>
Fri, 17 Feb 2017 11:25:17 +0000 (11:25 +0000)
Start using the Subtarget to make decisions about what's legal. In particular,
we only mark floating point operations as legal if we have VFP2, which is
something we should've done from the very start.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295439 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMLegalizerInfo.cpp
lib/Target/ARM/ARMLegalizerInfo.h
lib/Target/ARM/ARMTargetMachine.cpp
test/CodeGen/ARM/GlobalISel/arm-legalizer.mir

index a4f93b433f63349f8a454077d6f88f8ae291089b..ceebc39e8989202ecb3cac5680f826ce5738c7e6 100644 (file)
@@ -12,6 +12,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "ARMLegalizerInfo.h"
+#include "ARMSubtarget.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Type.h"
@@ -23,7 +24,7 @@ using namespace llvm;
 #error "You shouldn't build this"
 #endif
 
-ARMLegalizerInfo::ARMLegalizerInfo() {
+ARMLegalizerInfo::ARMLegalizerInfo(const ARMSubtarget &ST) {
   using namespace TargetOpcode;
 
   const LLT p0 = LLT::pointer(0, 32);
@@ -40,11 +41,6 @@ ARMLegalizerInfo::ARMLegalizerInfo() {
     setAction({G_LOAD, Ty}, Legal);
   setAction({G_LOAD, 1, p0}, Legal);
 
-  // FIXME: This is strictly for loading double-precision floating point values,
-  // if the hardware allows it. We rely on the instruction selector to complain
-  // otherwise.
-  setAction({G_LOAD, s64}, Legal);
-
   for (auto Ty : {s1, s8, s16, s32})
     setAction({G_ADD, Ty}, Legal);
 
@@ -54,10 +50,12 @@ ARMLegalizerInfo::ARMLegalizerInfo() {
       setAction({Op, 1, Ty}, Legal);
   }
 
-  // FIXME: This is a bit sloppy, but for now we'll just rely on the instruction
-  // selector to complain if it doesn't support floating point.
-  setAction({G_FADD, s32}, Legal);
-  setAction({G_FADD, s64}, Legal);
+  if (ST.hasVFP2()) {
+    setAction({G_FADD, s32}, Legal);
+    setAction({G_FADD, s64}, Legal);
+
+    setAction({G_LOAD, s64}, Legal);
+  }
 
   computeTables();
 }
index ca3eea81271bc1afab8c03b91c97029d6fd5d61b..0b8a608a6bdea077b811bb9c5d13d747bcc026cc 100644 (file)
 
 namespace llvm {
 
-class LLVMContext;
+class ARMSubtarget;
 
 /// This class provides the information for the target register banks.
 class ARMLegalizerInfo : public LegalizerInfo {
 public:
-  ARMLegalizerInfo();
+  ARMLegalizerInfo(const ARMSubtarget &ST);
 };
 } // End llvm namespace.
 #endif
index 98862d30fc49cbebf0da79efa5757dff8c4871b9..4225794d5492579e15d4623cc5e6dda0cb29bee4 100644 (file)
@@ -326,7 +326,7 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
 #else
     ARMGISelActualAccessor *GISel = new ARMGISelActualAccessor();
     GISel->CallLoweringInfo.reset(new ARMCallLowering(*I->getTargetLowering()));
-    GISel->Legalizer.reset(new ARMLegalizerInfo());
+    GISel->Legalizer.reset(new ARMLegalizerInfo(*I));
 
     auto *RBI = new ARMRegisterBankInfo(*I->getRegisterInfo());
 
index 61666153ed4287f90f6a6e64d0a19775ca3bb8a8..8ed4870ba89f892682c293099b5fbbe7d9579e8b 100644 (file)
@@ -8,10 +8,12 @@
   define void @test_add_s32() { ret void }
 
   define void @test_load_from_stack() { ret void }
-  define void @test_legal_loads() { ret void }
+  define void @test_legal_loads() #0 { ret void }
 
-  define void @test_fadd_s32() { ret void }
-  define void @test_fadd_s64() { ret void }
+  define void @test_fadd_s32() #0 { ret void }
+  define void @test_fadd_s64() #0 { ret void }
+
+  attributes #0 = { "target-features"="+vfp2" }
 ...
 ---
 name:            test_sext_s8