Commit Graph

4586 Commits

Author SHA1 Message Date
Fangrui Song c466264b34 Use the container form llvm::sort(C, ...)
There are a few leftovers in rL343163 which span two lines. This commit
changes these llvm::sort(C.begin(), C.end, ...) to llvm::sort(C, ...)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343426 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-30 22:31:29 +00:00
Fangrui Song 3b35e17b21 llvm::sort(C.begin(), C.end(), ...) -> llvm::sort(C, ...)
Summary: The convenience wrapper in STLExtras is available since rL342102.

Reviewers: dblaikie, javed.absar, JDevlieghere, andreadb

Subscribers: MatzeB, sanjoy, arsenm, dschuff, mehdi_amini, sdardis, nemanjai, jvesely, nhaehnle, sbc100, jgravelle-google, eraman, aheejin, kbarton, JDevlieghere, javed.absar, gbedwell, jrtc27, mgrang, atanasyan, steven_wu, george.burgess.iv, dexonsmith, kristina, jsji, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343163 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-27 02:13:45 +00:00
Clement Courbet afbc9614c0 [llvm-exegesis] Add support for measuring NumMicroOps.
Summary:
Example output for vzeroall:

---
mode:            uops
key:
  instructions:
    - 'VZEROALL'
  config:          ''
  register_initial_values:
cpu_name:        haswell
llvm_triple:     x86_64-unknown-linux-gnu
num_repetitions: 10000
measurements:
  - { debug_string: HWPort0, value: 0.0006, per_snippet_value: 0.0006,
      key: '3' }
  - { debug_string: HWPort1, value: 0.0011, per_snippet_value: 0.0011,
      key: '4' }
  - { debug_string: HWPort2, value: 0.0004, per_snippet_value: 0.0004,
      key: '5' }
  - { debug_string: HWPort3, value: 0.0018, per_snippet_value: 0.0018,
      key: '6' }
  - { debug_string: HWPort4, value: 0.0002, per_snippet_value: 0.0002,
      key: '7' }
  - { debug_string: HWPort5, value: 1.0019, per_snippet_value: 1.0019,
      key: '8' }
  - { debug_string: HWPort6, value: 1.0033, per_snippet_value: 1.0033,
      key: '9' }
  - { debug_string: HWPort7, value: 0.0001, per_snippet_value: 0.0001,
      key: '10' }
  - { debug_string: NumMicroOps, value: 20.0069, per_snippet_value: 20.0069,
      key: NumMicroOps }
error:           ''
info:            ''
assembled_snippet: C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C5FC77C3
...

Reviewers: gchatelet

Subscribers: tschuett, RKSimon, andreadb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343094 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-26 11:22:56 +00:00
Daniel Sanders c38849ca46 [globalisel][tblgen] Table optimization should consider the C++ code in C++ predicates
This fixes PR39045



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342997 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25 17:59:02 +00:00
Wouter van Oortmerssen 9dace88d8a [WebAssembly] Simplified selecting asmmatcher stack instructions.
Summary:
By using the existing isCodeGenOnly bit in the tablegen defs, as
suggested by tlively in https://reviews.llvm.org/D51662

Tested: llvm-lit -v `find test -name WebAssembly`

Reviewers: tlively

Subscribers: dschuff, sbc100, jgravelle-google, aheejin, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342772 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-21 20:53:55 +00:00
Wouter van Oortmerssen f67f1ae5c7 [WebAssembly] Made assembler only use stack instruction tablegen defs
Summary:
This ensures we have the non-register version of the instruction.

The stack version of call_indirect now wants a type index argument,
so that has been added in the existing tests.

Tested:
llvm-lit -v `find test -name WebAssembly`

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, aheejin, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342753 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-21 17:47:58 +00:00
Andrea Di Biagio eb2ecf38ab Attempt to unbreak buidlbot lld-x86_64-darwin13 after r342555.
The reason why build #25777 might have failed is because the SmallVector move
constructor is _not_ noexcept, and the stl implementation used by that buildbot
calls _VSTD::move_if_noexcept() (according to the backtrace).

OpcodeInfo has a default move constructor, and the copy constructor is deleted.
However, as far as I can see, SmallVector doesn't declare a noexcept move
constructor. So, what I believe it is happening here is that,
_VSTD::move_if_noexcept() returns an lvalue reference and not an rvalue
reference.
This eventually triggers a copy that fails to compile.

Hopefully, using a std::vector instead of SmallVector (as it was originally
suggested by Simon in the code review) should be enough to unbreak the buildbot.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342561 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 17:54:01 +00:00
Andrea Di Biagio a9c15c18d5 [TableGen][SubtargetEmitter] Add the ability for processor models to describe dependency breaking instructions.
This patch adds the ability for processor models to describe dependency breaking
instructions.

Different processors may specify a different set of dependency-breaking
instructions.
That means, we cannot assume that all processors of the same target would use
the same rules to classify dependency breaking instructions.

The main goal of this patch is to provide the means to describe dependency
breaking instructions directly via tablegen, and have the following
TargetSubtargetInfo hooks redefined in overrides by tabegen'd
XXXGenSubtargetInfo classes (here, XXX is a Target name).

```
virtual bool isZeroIdiom(const MachineInstr *MI, APInt &Mask) const {
  return false;
}

virtual bool isDependencyBreaking(const MachineInstr *MI, APInt &Mask) const {
  return isZeroIdiom(MI);
}
```

An instruction MI is a dependency-breaking instruction if a call to method
isDependencyBreaking(MI) on the STI (TargetSubtargetInfo object) evaluates to
true. Similarly, an instruction MI is a special case of zero-idiom dependency
breaking instruction if a call to STI.isZeroIdiom(MI) returns true.
The extra APInt is used for those targets that may want to select which machine
operands have their dependency broken (see comments in code).
Note that by default, subtargets don't know about the existence of
dependency-breaking. In the absence of external information, those method calls
would always return false.

A new tablegen class named STIPredicate has been added by this patch to let
processor models classify instructions that have properties in common. The idea
is that, a MCInstrPredicate definition can be used to "generate" an instruction
equivalence class, with the idea that instructions of a same class all have a
property in common.

STIPredicate definitions are essentially a collection of instruction equivalence
classes.
Also, different processor models can specify a different variant of the same
STIPredicate with different rules (i.e. predicates) to classify instructions.
Tablegen backends (in this particular case, the SubtargetEmitter) will be able
to process STIPredicate definitions, and automatically generate functions in
XXXGenSubtargetInfo.

This patch introduces two special kind of STIPredicate classes named
IsZeroIdiomFunction and IsDepBreakingFunction in tablegen. It also adds a
definition for those in the BtVer2 scheduling model only.

This patch supersedes the one committed at r338372 (phabricator review: D49310).

The main advantages are:
 - We can describe subtarget predicates via tablegen using STIPredicates.
 - We can describe zero-idioms / dep-breaking instructions directly via
   tablegen in the scheduling models.

In future, the STIPredicates framework can be used for solving other problems.
Examples of future developments are:
 - Teach how to identify optimizable register-register moves
 - Teach how to identify slow LEA instructions (each subtarget defining its own
   concept of "slow" LEA).
 - Teach how to identify instructions that have undocumented false dependencies
   on the output registers on some processors only.

It is also (in my opinion) an elegant way to expose knowledge to both external
tools like llvm-mca, and codegen passes.
For example, machine schedulers in LLVM could reuse that information when
internally constructing the data dependency graph for a code region.

This new design feature is also an "opt-in" feature. Processor models don't have
to use the new STIPredicates. It has all been designed to be as unintrusive as
possible.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342555 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 15:57:45 +00:00
Simon Pilgrim f02ce8dcad [TableGen] CodeGenDAGPatterns::GenerateVariants - use BitVector::set() where possible. NFCI.
In these cases we are always setting to true.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342543 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 12:23:50 +00:00
Simon Pilgrim 60bebed7a9 [TableGen] CodeGenDAGPatterns::GenerateVariants - use BitVector::push_back()
As mentioned on D52236, this saves 10secs in debug builds of x86 -gen-dag-isel

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342536 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-19 11:18:49 +00:00
Jinsong Ji c5c0a4b480 [NFC] Update comments regarding BufferSize for ProcResources
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342491 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 15:38:56 +00:00
Simon Pilgrim ff6f0e23ad Use pass-by-reference for-range loop. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342481 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 14:05:07 +00:00
Simon Pilgrim 275d69bc29 Fix signed/unsigned comparison warning. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342469 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 12:01:25 +00:00
Simon Pilgrim 686bd24614 [TableGen] CodeGenDAGPatterns::GenerateVariants - full caching of matching predicates
Further extension to D51035, this patch avoids all repeated predicates[] matching by caching as it collects the patterns that have multiple variants.

Saves around 25secs in debug builds of x86 -gen-dag-isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342467 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-18 11:30:30 +00:00
Josh Stone c1ddded1a5 Test commit: remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341966 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-11 17:28:43 +00:00
Wouter van Oortmerssen 9a75e493e8 [WebAssembly] Made disassembler only use stack instructions.
Summary:
Now uses the StackBased bit from the tablegen defs to identify
stack instructions (and ignore register based or non-wasm instructions).

Also changed how we store operands, since we now have up to 16 of them
per instruction. To not cause static data bloat, these are compressed
into a tiny table.

+ a few other cleanups.

Tested:
- MCTest
- llvm-lit -v `find test -name WebAssembly`

Reviewers: dschuff, jgravelle-google, sunfish, tlively

Subscribers: sbc100, aheejin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341081 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-30 15:40:53 +00:00
Simon Pilgrim 4b9c2a9039 Remove debug code accidently committed in rL340837. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340908 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 10:10:58 +00:00
Thomas Lively 31d4eb8d76 [WebAssembly][NFC] Document stackifier tablegen backend
Summary:
Add comments to help readers avoid having to read tablegen backends to
understand the code. Also remove unecessary breaks from the output.

Reviewers: dschuff, aheejin

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340864 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:49:47 +00:00
Thomas Lively 39e9b90909 [WebAssembly][NFC] Fix formatting from rL340781
Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340861 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:34:33 +00:00
Simon Pilgrim ac6174ed20 [TableGen] CodeGenDAGPatterns::GenerateVariants - basic caching of matching predicates
CodeGenDAGPatterns::GenerateVariants is a costly function in many tblgen commands (33.87% of the total runtime of x86 -gen-dag-isel), and due to the O(N^2) nature of the function, there are a high number of repeated comparisons of the pattern's vector<Predicate>.

This initial patch at least avoids repeating these comparisons for every Variant in a pattern. I began investigating caching all the matches before entering the loop but hit issues with how best to store the data and how to update the cache as patterns were added.

Saves around 15secs in debug builds of x86 -gen-dag-isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340837 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 15:42:08 +00:00
Simon Pilgrim 24696e2bdf [TableGen] Use std::move where possible in InstructionMemo constructor. NFCI.
Requested in post-commit review for rL339670

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340819 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 11:10:27 +00:00
Thomas Lively cef9a05f4d [WebAssembly] TableGen backend for stackifying instructions
Summary:
The new stackification backend generates the giant switch statement
used to translate instructions to their stackified forms. I did this
because it was more interesting than adding all the different vector
versions of the various SIMD instructions to the switch statment
manually.

Reviewers: aardappel, aheejin, dschuff

Subscribers: mgorny, sbc100, jgravelle-google, sunfish, jfb, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340781 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 22:02:09 +00:00
Nicolai Haehnle 286f6b5473 TableGen/SearchableTables: Cast enums to unsigned in generated code
Summary:
This should fix signedness warnings when compiling with MSVC.

Change-Id: I4664cce0ba91e9b42d21a86fd4a7e82f2320c451

Reviewers: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340518 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 08:02:02 +00:00
Heejin Ahn 408053d6cd [WebAssembly] Add isEHScopeReturn instruction property
Summary:
So far, `isReturn` property is used to mean both a return instruction
from a functon and the end of an EH scope, a scope that starts with a EH
scope entry BB and ends with a catchret or a cleanupret instruction.
Because WinEH uses funclets, all EH-scope-ending instructions are also
real return instruction from a function. But for wasm, they only serve
as the end marker of an EH scope but not a return instruction that
exits a function. This mismatch caused incorrect prolog and epilog
generation in wasm EH scopes. This patch fixes this.

This patch is in the same vein with rL333045, which splits
`MachineBasicBlock::isEHFuncletEntry` into `isEHFuncletEntry` and
`isEHScopeEntry`.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340325 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:44:11 +00:00
Simon Pilgrim 545c5cb20b [TableGen] Don't separately search for DefaultMode when we're going to iterate the set anyway. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340055 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 17:45:15 +00:00
Simon Pilgrim 8f78389285 [TableGen] TypeInfer - Cache the legal types as TypeSetByHwMode
We were just caching the MVT set of legal types, then every call creating a new TypeSetByHwMode with it and passing it back on the stack. There's no need to do this - we can create and cache the whole TypeSetByHwMode once and return a const reference to it each time.

Additionally, TypeInfer::expandOverloads wasn't making use of the fact that the cache just contains a default mode containing all the types.

Saves up to 30secs in debug builds of x86 -gen-dag-isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340042 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 15:54:07 +00:00
Simon Pilgrim e1166b22b6 [TableGen] TypeSetByHwMode::insert - cache the default MVT. NFCI.
Avoids repeated count()/find() calls that we've already have the default values for.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340020 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 13:03:17 +00:00
Simon Pilgrim fc96bec77d [TableGen] TypeSetByHwMode::operator== optimization
This operator is called a great deal, by checking for the cheap isSimple equality cases first (a common occurrence) we can improve performance as we avoid a lot of std::map find/iteration in hasDefault.

isSimple also means that a default value is present, so we can avoid some hasDefault calls.

This also avoids a rather dodgy piece of logic that was checking for isSimple() && !VTS.isSimple() but not the inverse - it now uses the general hasDefault mode comparison test instead.

Saves around 15secs in debug builds of x86 -gen-dag-isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339890 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-16 16:16:28 +00:00
Simon Pilgrim 37d2a3546f [TableGen] Avoid self getPredicates() != comparison. NFCI.
We were performing a completely unnecessary full comparison of the same std::vector<Predicate>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339888 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-16 16:04:05 +00:00
Simon Pilgrim 46fd9f609b [TableGen] Return ValueTypeByHwMode by const reference from CodeGenRegisterClass::getValueTypeNum
Avoids costly std::map copies inside ValueTypeByHwMode constructor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339884 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-16 15:29:24 +00:00
Simon Pilgrim 1cdda230e9 [TableGen] Remove unnecessary TypeSetByHwMode -> ValueTypeByHwMode -> TypeSetByHwMode conversions in getPatternSize
I noticed this during profiling of tablegen (PR28222) that we were calling Child->getType(0) which creates a ValueTypeByHwMode on the fly from the requested internal TypeSetByHwMode type and returns it by value, we then treat it as a TypeSetByHwMode reference which involves constructing a new TypeSetByHwMode on the stack with a large amount of std::map iterating/copying all along the way.

I am not an expert on tablegen, but AFAICT this is all unnecessary and we should be calling Child->getExtType(0) which returns the original TypeSetByHwMode by reference.

This gives me a 90sec reduction in msvc debug builds of x86 -gen-dag-isel.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339812 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 20:41:19 +00:00
Andrea Di Biagio e9759ddbdc [Tablegen][MCInstPredicate] Removed redundant template argument from class TIIPredicate, and implemented verification rules for TIIPredicates.
This patch removes redundant template argument `TargetName` from TIIPredicate.
Tablegen can always infer the target name from the context. So we don't need to
force users of TIIPredicate to always specify it.

This allows us to better modularize the tablegen class hierarchy for the
so-called "function predicates". class FunctionPredicateBase has been added; it
is currently used as a building block for TIIPredicates. However, I plan to
reuse that class to model other function predicate classes too (i.e. not just
TIIPredicates). For example, this can be a first step towards implementing
proper support for dependency breaking instructions in tablegen.

This patch also adds a verification step on TIIPredicates in tablegen.
We cannot have multiple TIIPredicates with the same name. Otherwise, this will
cause build errors later on, when tablegen'd .inc files are included by cpp
files and then compiled.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339706 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 18:36:54 +00:00
Simon Pilgrim 62fcc62230 [TableGen] Pass string/vector types by const reference (PR37666). NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339670 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 11:17:38 +00:00
Craig Topper 656d5d59d3 [X86] Don't ignore 0x66 prefix on relative jumps in 64-bit mode. Fix opcode selection of relative jumps in 16-bit mode. Treat jno/jo like other jcc instructions.
The behavior in 64-bit mode is different between Intel and AMD CPUs. Intel ignores the 0x66 prefix. AMD does not. objump doesn't ignore the 0x66 prefix. Since LLVM aims to match objdump behavior, we should do the same.

While I was trying to fix this I had change brtarget16/32 to use ENCODING_IW/ID instead of ENCODING_Iv to get the 0x66+REX.W case to act sort of sanely. It's still wrong, but that's a problem for another day.

The change in encoding exposed the fact that 16-bit mode disassembly of relative jumps was creating JMP_4 with a 2 byte immediate. It should have been JMP_2. From just printing you can't tell the difference, but if you dumped the encoding it wouldn't have matched what we started with.

While fixing that, it exposed that jo/jno opcodes were missing from the switch that this patch deleted and there were no test cases for them.

Fixes PR38537.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339622 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 22:06:28 +00:00
Andrea Di Biagio 87972c4919 [Tablegen] Replace uses of formatted_raw_ostream with raw_ostream in the predicate expander. NFCI
This is a follow-up of r339552.

As pointed out by Craig in D50566, we don't need a formatted_raw_ostream to
indent strings. We can use instead raw_ostream::indent().

Internally, class PredicateExpander already keeps track of the current
indentation level. Also, the grammar for predicates is well parenthesized, and
therefore we don't need to use a formatted_raw_ostream to continuously track the
column number. Instead we can safely replace all the uses of
formatted_raw_ostream::PadToColumn() with uses of raw_ostream::indent().

By replacing formatted_raw_ostream with a simpler raw_ostream, we also avoid the
implicit check on the newline character on every print to stream.

No functional change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339577 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 15:13:35 +00:00
Andrea Di Biagio 61e1c20944 [Tablegen][SubtargetEmitter] Improve expansion of predicates of a variant scheduling class.
This patch refactors the logic that expands predicates of a variant scheduling
class.

The idea is to improve the readability of the auto-generated code by removing
redundant parentheses around predicate expressions, and by removing redundant
if(true) statements.

This patch replaces the definition of NoSchedPred in TargetSchedule.td with an
instance of MCSchedPredicate. The new definition is sematically equivalent to
the previous one. The main difference is that now SubtargetEmitter knows that it
represents predicate "true".

Before this patch, we always generated an if (true) for the default transition
of a variant scheduling class.

Example (taken from AArch64GenSubtargetInfo.inc) :

```
if (SchedModel->getProcessorID() == 3) { // CycloneModel
  if ((TII->isScaledAddr(*MI)))
    return 927; // (WriteIS_WriteLD)_ReadBaseRS
  if ((true))
    return 928; // WriteLD_ReadDefault
}
```

Extra parentheses were also generated around the predicate expressions.

With this patch, we get the following auto-generated checks:

```
if (SchedModel->getProcessorID() == 3) { // CycloneModel
  if (TII->isScaledAddr(*MI))
    return 927; // (WriteIS_WriteLD)_ReadBaseRS
  return 928; // WriteLD_ReadDefault
}
```

The new auto-generated code behaves exactly the same as before. So, technically
this is a non functional change.

Differential revision: https://reviews.llvm.org/D50566


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339552 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 11:09:04 +00:00
Daniel Sanders d0ee5d297e [globalisel] Remove dead code from GlobalISelEmitter
Summary: Found by GCC's -Wunused-function.

Patch by Kim Gräsman

Reviewers: ab, dsanders, llvm-commits

Reviewed By: dsanders

Subscribers: rovka, kristof.beyls

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339528 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-12 21:49:42 +00:00
Andrea Di Biagio 6ec2af8bc6 [Tablegen][SubtargetEmitter] refactor method emitSchedModelHelpersImpl(). NFCI
Part of the logic has been moved to helper functions to (hopefully) improve
readability.
Added a few code comments to better describe how the algorithm works.

No functional change intended.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339421 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 10:43:43 +00:00
Andrea Di Biagio d99d65710d [MC][PredicateExpander] Extend the grammar to support simple switch and return statements.
This patch introduces tablegen class MCStatement.

Currently, an MCStatement can be either a return statement, or a switch
statement.

```
MCStatement:
   MCReturnStatement
   MCOpcodeSwitchStatement
```

A MCReturnStatement expands to a return statement, and the boolean expression
associated with the return statement is described by a MCInstPredicate.

An MCOpcodeSwitchStatement is a switch statement where the condition is a check
on the machine opcode. It allows the definition of multiple checks, as well as a
default case. More details on the grammar implemented by these two new
constructs can be found in the diff for TargetInstrPredicates.td.

This patch makes it easier to read the body of auto-generated TargetInstrInfo
predicates.

In future, I plan to reuse/extend the MCStatement grammar to describe more
complex target hooks. For now, this is just a first step (mostly a minor
cosmetic change to polish the new predicates framework).

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339352 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 15:32:48 +00:00
Bjorn Pettersson ead8b39fb5 [MC] Remove PhysRegSize from MCRegisterClass
Summary:
The interface to get size and spill size of a register
was moved from MCRegisterInfo to TargetRegisterInfo over
a year ago. Afaik the old interface has bee around
to give out-of-tree targets a chance to adapt to the
new interface.

One problem with the old MCRegisterClass::PhysRegSize was that
it represented the size of a register as "size in bits" / 8.
So a register had to be a multiple of eight bits wide for the
size to be correct (and the byte size for the target needed to
be eight bits).

Reviewers: kparzysz, qcolombet

Reviewed By: kparzysz

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339350 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 15:19:07 +00:00
Daniel Sanders 70dbc396c8 [tablegen] Improve performance of -gen-register-info by replacing barely-necessary std::map with a sorted vector
Summary:
This particular map is hardly ever queried and has a phased usage pattern (insert,
iterate, query, insert, iterate) so it's a good candidate for a sorted vector and
std::lower_bound.

This significantly reduces the run time of runTargetDesc() in some circumstances.
One llvm-tblgen invocation in my build improves the time spent in runTargetDesc()
from 9.86s down to 0.80s (~92%) without changing the output. The same invocation
also has 2GB less allocation churn.

Reviewers: bogner, rtereshin, aditya_nandakumar, volkan

Reviewed By: rtereshin

Subscribers: mgrang, dexonsmith, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339208 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-08 00:19:59 +00:00
Ulrich Weigand 185957447e Fix build bot after r338521
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338522 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 12:07:32 +00:00
Ulrich Weigand afca5c23cf [SystemZ, TableGen] Fix shift count handling
The DAG combiner logic to simplify AND masks in shift counts is invalid.
While it is true that the SystemZ shift instructions ignore all but the
low 6 bits of the shift count, it is still invalid to simplify the AND
masks while the DAG still uses the standard shift operators (which are
*not* defined to match the SystemZ instruction behavior).

Instead, this patch performs equivalent operations during instruction
selection. For completely removing the AND, this now happens via
additional DAG match patterns implemented by a multi-alternative
PatFrags. For simplifying a 32-bit AND to a 16-bit AND, the existing DAG
patterns were already mostly OK, they just needed an output XForm to
actually truncate the immediate value.

Unfortunately, the latter change also exposed a bug in TableGen: it
seems XForms are currently only handled correctly for direct operands of
the outermost operation node. This patch also fixes that bug by simply
recurring through the whole pattern. This should be NFC for all other
targets.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338521 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-01 11:57:58 +00:00
Simon Pilgrim 947573c21d Revert r338365: [X86] Improved sched models for X86 BT*rr instructions.
https://reviews.llvm.org/D49243

Contains WIP code that should not have been included.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338369 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 13:00:51 +00:00
Andrew V. Tischenko b80d74e072 [X86] Improved sched models for X86 BT*rr instructions.
https://reviews.llvm.org/D49243


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-31 12:33:48 +00:00
Stella Stamenova 4f30db4325 [windows] Don't inline fieldFromInstruction on Windows
Summary:
The VS compiler (on Windows) has a bug which results in fieldFromInstruction being optimized out in some circumstances. This only happens in *release no debug info* builds that have assertions *turned off* - in all other situations the function is not inlined, so the functionality is correct. All of the bots have assertions turned on, so this path is not regularly tested. The workaround is to not inline the function on Windows - if the bug is fixed in a later release of the VS compiler, the noinline specification can be removed.

The test that consistently reproduces this is Lanai v11.txt test.

Reviewers: asmith, labath, zturner

Subscribers: dblaikie, stella.stamenova, aprantl, JDevlieghere, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337942 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-25 17:33:20 +00:00
Andrea Di Biagio 3ac65c443f [Tablegen][PredicateExpander] Add the ability to define checks for invalid registers.
This was discussed in review D49436.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337378 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-18 11:03:22 +00:00
Andrea Di Biagio 1885077d4c [Tablegen][PredicateExpander] Fix a bug in expandCheckImmOperand.
Function `expandCheckImmOperand` should always check if the input machine
instruction is passed by reference before calling method `getOperand()` on it.

Found while working on a patch that relies on `expandCheckImmOperand` to expand
a scheduling predicate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337294 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-17 16:11:37 +00:00
Craig Topper cfe3c91526 [TableGen] std::move vectors into TreePatternNode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337121 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-15 06:52:49 +00:00
Craig Topper ecb8905452 [TableGen] Remove what seems to be an unnecessary std::map copy.
The comment says the copy was made so it could be destroyed in the following loop, but the original map wasn't used after the loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337120 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-15 06:52:48 +00:00