summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64
diff options
context:
space:
mode:
authorAhmed Bougacha <ahmed.bougacha@gmail.com>2016-12-21 23:26:20 +0000
committerAhmed Bougacha <ahmed.bougacha@gmail.com>2016-12-21 23:26:20 +0000
commit36f7035bd7d0e99abfc362da20894388c2515605 (patch)
treea640aa3559a78de0475e100ec63089300a18ec06 /llvm/lib/Target/AArch64
parentaa9fe53278677f6f80a4b05476da47d06bf1e584 (diff)
downloadbcm5719-llvm-36f7035bd7d0e99abfc362da20894388c2515605.tar.gz
bcm5719-llvm-36f7035bd7d0e99abfc362da20894388c2515605.zip
[GlobalISel] Add basic Selector-emitter tblgen backend.
This adds a basic tablegen backend that analyzes the SelectionDAG patterns to find simple ones that are eligible for GlobalISel-emission. That's similar to FastISel, with one notable difference: we're not fed ISD opcodes, so we need to map the SDNode operators to generic opcodes. That's done using GINodeEquiv in TargetGlobalISel.td. Otherwise, this is mostly boilerplate, and lots of filtering of any kind of "complicated" pattern. On AArch64, this is sufficient to match G_ADD up to s64 (to ADDWrr/ADDXrr) and G_BR (to B). Differential Revision: https://reviews.llvm.org/D26878 llvm-svn: 290284
Diffstat (limited to 'llvm/lib/Target/AArch64')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp12
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstructionSelector.h4
-rw-r--r--llvm/lib/Target/AArch64/CMakeLists.txt3
3 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
index 4274b4080cc..20de07424c5 100644
--- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
@@ -36,6 +36,8 @@ using namespace llvm;
#error "You shouldn't build this"
#endif
+#include "AArch64GenGlobalISel.inc"
+
AArch64InstructionSelector::AArch64InstructionSelector(
const AArch64TargetMachine &TM, const AArch64Subtarget &STI,
const AArch64RegisterBankInfo &RBI)
@@ -139,6 +141,7 @@ static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID,
case TargetOpcode::G_AND:
return AArch64::ANDWrr;
case TargetOpcode::G_ADD:
+ assert(OpSize != 32 && "s32 G_ADD should have been selected");
return AArch64::ADDWrr;
case TargetOpcode::G_SUB:
return AArch64::SUBWrr;
@@ -163,7 +166,6 @@ static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID,
return AArch64::EORXrr;
case TargetOpcode::G_AND:
return AArch64::ANDXrr;
- case TargetOpcode::G_ADD:
case TargetOpcode::G_GEP:
return AArch64::ADDXrr;
case TargetOpcode::G_SUB:
@@ -527,15 +529,13 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
return false;
}
+ if (selectImpl(I))
+ return true;
+
LLT Ty =
I.getOperand(0).isReg() ? MRI.getType(I.getOperand(0).getReg()) : LLT{};
switch (Opcode) {
- case TargetOpcode::G_BR: {
- I.setDesc(TII.get(AArch64::B));
- return true;
- }
-
case TargetOpcode::G_BRCOND: {
if (Ty.getSizeInBits() > 32) {
// We shouldn't need this on AArch64, but it would be implemented as an
diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.h b/llvm/lib/Target/AArch64/AArch64InstructionSelector.h
index 97e1b58400e..0d44e696ac2 100644
--- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.h
+++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.h
@@ -32,6 +32,10 @@ public:
virtual bool select(MachineInstr &I) const override;
private:
+ /// tblgen-erated 'select' implementation, used as the initial selector for
+ /// the patterns that don't require complex C++.
+ bool selectImpl(MachineInstr &I) const;
+
const AArch64TargetMachine &TM;
const AArch64Subtarget &STI;
const AArch64InstrInfo &TII;
diff --git a/llvm/lib/Target/AArch64/CMakeLists.txt b/llvm/lib/Target/AArch64/CMakeLists.txt
index 5c835eafb7e..6bcf67fb3fe 100644
--- a/llvm/lib/Target/AArch64/CMakeLists.txt
+++ b/llvm/lib/Target/AArch64/CMakeLists.txt
@@ -13,6 +13,9 @@ tablegen(LLVM AArch64GenCallingConv.inc -gen-callingconv)
tablegen(LLVM AArch64GenSubtargetInfo.inc -gen-subtarget)
tablegen(LLVM AArch64GenDisassemblerTables.inc -gen-disassembler)
tablegen(LLVM AArch64GenSystemOperands.inc -gen-searchable-tables)
+if(LLVM_BUILD_GLOBAL_ISEL)
+ tablegen(LLVM AArch64GenGlobalISel.inc -gen-global-isel)
+endif()
add_public_tablegen_target(AArch64CommonTableGen)
OpenPOWER on IntegriCloud