[llvm] r295439 - [ARM] GlobalISel: Use Subtarget in Legalizer
Diana Picus via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 17 03:25:17 PST 2017
Author: rovka
Date: Fri Feb 17 05:25:17 2017
New Revision: 295439
URL: http://llvm.org/viewvc/llvm-project?rev=295439&view=rev
Log:
[ARM] GlobalISel: Use Subtarget in Legalizer
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.
Modified:
llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp
llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.h
llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir
Modified: llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp?rev=295439&r1=295438&r2=295439&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.cpp Fri Feb 17 05:25:17 2017
@@ -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();
}
Modified: llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.h?rev=295439&r1=295438&r2=295439&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.h (original)
+++ llvm/trunk/lib/Target/ARM/ARMLegalizerInfo.h Fri Feb 17 05:25:17 2017
@@ -18,12 +18,12 @@
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
Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=295439&r1=295438&r2=295439&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Fri Feb 17 05:25:17 2017
@@ -326,7 +326,7 @@ ARMBaseTargetMachine::getSubtargetImpl(c
#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());
Modified: llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir?rev=295439&r1=295438&r2=295439&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir (original)
+++ llvm/trunk/test/CodeGen/ARM/GlobalISel/arm-legalizer.mir Fri Feb 17 05:25:17 2017
@@ -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
More information about the llvm-commits
mailing list