267 Commits

Author SHA1 Message Date
Diana Picus
b1879fb1fb [ARM] GlobalISel: Select add i32, i32
Add the minimal support necessary to select a function that returns the sum of
two i32 values.

This includes some support for argument/return lowering of i32 values through
registers, as well as the handling of copy and add instructions throughout the
GlobalISel pipeline.

Differential Revision: https://reviews.llvm.org/D26677

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289940 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-16 12:54:46 +00:00
Quentin Colombet
e886ddf8d4 [IRTranslator] Merge the entry and ABI lowering blocks.
The IRTranslator uses an additional block before the LLVM-IR entry block
to perform all the ABI lowering and the constant hoisting. Thus, this
block is the actual entry block and it falls through the LLVM-IR entry
block. However, with such representation, we end up with two basic
blocks that are not maximal.

Therefore, this patch adds a bit of canonicalization by merging both the
LLVM-IR entry block and the ABI lowering/constants hoisting into one
block, making the resulting block more likely to be maximal (indeed the
LLVM-IR entry block might not have been maximal).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289891 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15 23:32:25 +00:00
Diana Picus
c997cb8c2a [GlobalISel] Move extendRegister where it belongs. NFCI
Apparently I missed this one when I moved ValueHandler back in r288658. Sorry!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289528 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-13 10:46:12 +00:00
Tim Northover
a6b6846c2f GlobalISel: fall back gracefully for debug intrinsics.
Supporting them properly is a reasonably complex chunk of work, so to allow bot
testing before then we should at least be able to fall back to DAG ISel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289150 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 22:44:13 +00:00
Tim Northover
8fd7b713cc GlobalISel: factor overflow handling into separate function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289149 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 22:44:00 +00:00
Tim Northover
4f7586098b GlobalISel: use correct builder for ConstantExprs.
ConstantExpr instances were emitting code into the current block rather than
the entry block. This meant they didn't necessarily dominate all uses, which is
clearly wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288985 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 21:29:15 +00:00
Tim Northover
66746a7ae1 GlobalISel: store the current MachineFunction as direct state. NFC.
Having to ask the MIRBuilder for the current function is a little awkward, and
I'm intending to improve how that's threaded through anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288983 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 21:17:47 +00:00
Tim Northover
06bfcf3df9 GlobalISel: simplify MachineIRBuilder interface.
MachineIRBuilder had weird before/after and beginning/end flags for the insert
point. Unfortunately the non-default means that instructions will be inserted
in reverse order which is almost never what anyone wants.

Really, I think we just want (like IRBuilder has) the ability to insert at any
C++ iterator-style point (i.e. before any instruction or before MBB.end()). So
this fixes MIRBuilders to behave like IRBuilders in this respect.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288980 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-07 21:05:38 +00:00
Tim Northover
2c23a5b605 GlobalISel: correctly handle small args via memory.
We were rounding size in bits down rather than up, leading to 0-sized slots for
i1 (assert!) and bugs for other types not byte-aligned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288848 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 21:02:19 +00:00
Tim Northover
9c3d059fa2 GlobalISel: fall back gracefully when we hit unhandled legalizer default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288840 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 19:02:15 +00:00
Tim Northover
3a783f8716 GlobalISel: handle G_SEQUENCE fallbacks gracefully.
There were two problems:
  + AArch64 was reusing random data from its binary op tables, which is
    complete nonsense for G_SEQUENCE.
  + Even when AArch64 gave up and said it couldn't handle G_SEQUENCE,
    the generic code asserted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288836 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 18:38:38 +00:00
Tim Northover
22c48aa20e GlobalISel: allow G_SELECT instructions for pointers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288835 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 18:38:34 +00:00
Tim Northover
a5cd8a603e GlobalISel: stop the legalizer from trying to handle oddly-sized types.
It'll almost immediately fail because it always tries to half/double the size
until it finds a legal one. Unfortunately, this triggers an assertion
preventing the DAG fallback from being possible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288834 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 18:38:29 +00:00
Sam McCall
ec5ae20d53 Add missing parens in assert.
Summary: Add missing parens in assert, which warn in GCC.

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D27448

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288792 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 10:14:36 +00:00
Tim Northover
416ccca7e0 GlobalISel: avoid looking too closely at PHIs when we bail.
The function used to finish off PHIs by adding the relevant basic blocks can
fail if we're aborting and still don't actually have the needed
MachineBasicBlocks. So avoid trying in that case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288727 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 23:10:19 +00:00
Tim Northover
9fef274c6a GlobalISel: place constants correctly in the entry block.
When the entry block was empty after arg lowering, we were always placing
constants at the end. This is probably hamrless while translating the same
block, but horribly wrong once its terminator has been translated. So switch to
inserting at the beginning.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288720 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 22:40:13 +00:00
Tim Northover
75dfa0e7c6 GlobalISel: handle pointer arguments that get assigned to the stack.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288717 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 22:20:32 +00:00
Tim Northover
e1db4f7b15 GlobalISel: translate constants larger than 64 bits.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288713 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 21:54:17 +00:00
Tim Northover
ad46a07d21 GlobalISel: make G_CONSTANT take a ConstantInt rather than int64_t.
This makes it more similar to the floating-point constant, and also allows for
larger constants to be translated later. There's no real functional change in
this patch though, just syntax updates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288712 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 21:47:07 +00:00
Tim Northover
bcadc2717e GlobalISel: improve translation fallback for constants.
Returning 0 (NoReg) from getOrCreateVReg leads to unexpected situations later
in the translation. It's better to return a valid (if undefined) register and
let the rest of the instruction carry on as planned.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288709 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 21:40:33 +00:00
Diana Picus
0eeb88bc21 [GlobalISel] Extract handleAssignments out of AArch64CallLowering
This function seems target-independent so far: all the target-specific behaviour
is isolated in the CCAssignFn and the ValueHandler (which we're also extracting
into the generic CallLowering).

The intention is to use this in the ARM backend.

Differential Revision: https://reviews.llvm.org/D27045

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288658 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 10:40:33 +00:00
Peter Collingbourne
f5bbb38c1a Fix GlobalISel build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288460 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 02:55:30 +00:00
Matthias Braun
347847bcdc Move most EH from MachineModuleInfo to MachineFunction
Recommitting r288293 with some extra fixes for GlobalISel code.

Most of the exception handling members in MachineModuleInfo is actually
per function data (talks about the "current function") so it is better
to keep it at the function instead of the module.

This is a necessary step to have machine module passes work properly.

Also:
- Rename TidyLandingPads() to tidyLandingPads()
- Use doxygen member groups instead of "//===- EH ---"... so it is clear
  where a group ends.
- I had to add an ugly const_cast at two places in the AsmPrinter
  because the available MachineFunction pointers are const, but the code
  wants to call tidyLandingPads() in between
  (markFunctionEnd()/endFunction()).

Differential Revision: https://reviews.llvm.org/D27227

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288405 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-01 19:32:15 +00:00
Tom Stellard
eb3384582f GlobalISel: Fix unconditional fallback with global isel abort is disabled
Reviewers: t.p.northover, ab, qcolombet

Subscribers: mehdi_amini, vkalintiris, wdng, dberris, llvm-commits, rovka

Differential Revision: https://reviews.llvm.org/D26765

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287344 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18 14:14:35 +00:00
Chris Bieneman
92cb3eecbd [CMake] NFC. Updating CMake dependency specifications
This patch updates a bunch of places where add_dependencies was being explicitly called to add dependencies on intrinsics_gen to instead use the DEPENDS named parameter. This cleanup is needed for a patch I'm working on to add a dependency debugging mode to the build system.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287206 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-17 04:36:50 +00:00
Ahmed Bougacha
03cebfbba9 [CodeGen] Pass references, not pointers, to MMI helpers. NFC.
While there, rename them to follow the coding style.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287169 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-16 22:25:03 +00:00
Ahmed Bougacha
75fc88218c Revert "Get GlobalISel to build on Linux after r286407"
This reverts commit r286962.

We want to avoid depending on SelectionDAG, and AddLandingPadInfo
lives in CodeGen now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287168 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-16 22:24:59 +00:00
Ahmed Bougacha
f522e20fe6 [CodeGen] Pull MMI helpers from FunctionLoweringInfo to MMI. NFC.
They're not SelectionDAG- or FunctionLoweringInfo-specific.  They
are, however, specific to building MMI from IR.
We could make them members, but it's nice having MMI be a "simple" data
structure and this logic kept separate.

This also lets us reuse them from GlobalISel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287167 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-16 22:24:56 +00:00
Diana Picus
6ee545953f Get GlobalISel to build on Linux after r286407
r286407 has introduced calls to llvm::AddLandingPadInfo, which lives in the
SelectionDAG component. Add it to LLVMBuild to avoid linker failures on Linux.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286962 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15 14:11:11 +00:00
Diana Picus
e16596f28c GlobalISel: Fix indentation. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286808 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-14 10:25:43 +00:00
Tim Northover
5224b5a0c9 GlobalISel: fix typo. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286408 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-09 22:40:02 +00:00
Tim Northover
e6797b7d75 GlobalISel: translate invoke and landingpad instructions
Pretty bare-bones support for exception handling (no weird MSVC stuff, no SjLj
etc), but it should get things going.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286407 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-09 22:39:54 +00:00
David L. Jones
c457ee1edb GlobalISel: make sure debugging variables are appropriately elided in release builds.
Summary:
There are two variables here that break. This change constrains both of them to
debug builds (via DEBUG() or #ifndef NDEBUG).

Reviewers: bkramer, t.p.northover

Subscribers: mehdi_amini, vkalintiris

Differential Revision: https://reviews.llvm.org/D26421

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286300 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 22:03:23 +00:00
Tim Northover
474c83f1b3 GlobalISel: allow CodeGen to fallback on VReg type/class issues.
After instruction selection we perform some checks on each VReg just before
discarding the type information. These checks were assertions before, but that
breaks the fallback path so this patch moves the logic into the main flow and
reports a better error on failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286289 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 20:39:03 +00:00
Ahmed Bougacha
9da8087b94 [GlobalISel] Dump all instructions inserted by selector.
This is helpful when multiple instructions are inserted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286273 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 19:27:13 +00:00
Ahmed Bougacha
86b25f1697 [GlobalISel] Permit select() to erase.
Erasing reverse_iterators is problematic; iterate manually.
While there, keep track of the range of inserted instructions.
It can miss instructions inserted elsewhere, but those are harder
to track.

Differential Revision: http://reviews.llvm.org/D22924

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286272 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 19:27:10 +00:00
Tim Northover
160a2705e6 GlobalISel: improve error diagnostics when IRTranslation fails.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286190 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-08 01:12:17 +00:00
Tim Northover
fa8311d1c9 GlobalISel: translate stack protector intrinsics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285614 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-31 18:30:59 +00:00
Tim Northover
96f32a0e61 Revert r284604. A.K.A. "TMP"
Committed by mistake.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284606 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 15:56:12 +00:00
Tim Northover
ef2c5dd55c TMP
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284604 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 15:55:09 +00:00
Tim Northover
dc8499fbc7 GlobalISel: support translating volatile loads and stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284603 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19 15:55:06 +00:00
Tim Northover
55352d9d36 GlobalISel: translate the @llvm.objectsize intrinsic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284527 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-18 20:03:51 +00:00
Tim Northover
4841e615e3 GlobalISel: translate memcpy intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284525 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-18 20:03:45 +00:00
Tim Northover
ee325b9e96 GlobalISel: rename legalizer components to match others.
The previous names were both misleading (the MachineLegalizer actually
contained the info tables) and inconsistent with the selector & translator (in
having a "Machine") prefix. This should make everything sensible again.

The only functional change is the name of a couple of command-line options.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284287 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-14 22:18:18 +00:00
Tim Northover
b725b3cddf GlobalISel: select G_GLOBAL_VALUE uses on AArch64.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283809 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-10 21:50:00 +00:00
Mehdi Amini
3ffe113e11 Turn cl::values() (for enum) from a vararg function to using C++ variadic template
The core of the change is supposed to be NFC, however it also fixes
what I believe was an undefined behavior when calling:

 va_start(ValueArgs, Desc);

with Desc being a StringRef.

Differential Revision: https://reviews.llvm.org/D25342

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283671 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-08 19:41:06 +00:00
Quentin Colombet
97fcd6ea2e [RegisterBankInfo] Change the default mapping for Copy and PHI.
Instead of producing a mapping for all the operands, we only generate a
mapping for the definition. Indeed, the other operands are not
constrained by the instruction and thus, we should leave the choice to
the actual definition to do the right thing.

In pratice this is almost NFC, but with one advantage. We will have only
one instance of OperandsMapping for each copy and phi that map to one
register bank instead of one different instance for each different
number of operands for each copy and phi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282756 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-29 19:51:46 +00:00
Quentin Colombet
1deea86d16 [RegisterBankInfo] Uniquely generate OperandsMapping.
This is a step toward statically allocate InstructionMapping. Like the
previous few commits, the goal is to move toward a TableGen'ed like
structure with no dynamic allocation at all.

This should already improve compile time by getting rid of a bunch of
memmove of SmallVectors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282643 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-28 22:20:49 +00:00
Quentin Colombet
5c6805e527 [RegisterBankInfo] Rework the APIs of ValueMapping.
This is a preparatory commit for more TableGen-like structure.
NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-28 22:20:24 +00:00
Quentin Colombet
9b473140dd [RegisterBankInfo] Constify the member of the XXXMapping maps.
This makes it obvious that items in those maps behave like statically
created objects.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282327 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-24 04:54:03 +00:00