1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 19:42:54 +02:00
llvm-mirror/include/llvm
Ulrich Weigand 535942804d [TableGen] Support multi-alternative pattern fragments
A TableGen instruction record usually contains a DAG pattern that will
describe the SelectionDAG operation that can be implemented by this
instruction. However, there will be cases where several different DAG
patterns can all be implemented by the same instruction. The way to
represent this today is to write additional patterns in the Pattern
(or usually Pat) class that map those extra DAG patterns to the
instruction. This usually also works fine.

However, I've noticed cases where the current setup seems to require
quite a bit of extra (and duplicated) text in the target .td files.
For example, in the SystemZ back-end, there are quite a number of
instructions that can implement an "add-with-overflow" operation.
The same instructions also need to be used to implement just plain
addition (simply ignoring the extra overflow output). The current
solution requires creating extra Pat pattern for every instruction,
duplicating the information about which particular add operands
map best to which particular instruction.

This patch enhances TableGen to support a new PatFrags class, which
can be used to encapsulate multiple alternative patterns that may
all match to the same instruction.  It operates the same way as the
existing PatFrag class, except that it accepts a list of DAG patterns
to match instead of just a single one.  As an example, we can now define
a PatFrags to match either an "add-with-overflow" or a regular add
operation:

  def z_sadd : PatFrags<(ops node:$src1, node:$src2),
                        [(z_saddo node:$src1, node:$src2),
                         (add node:$src1, node:$src2)]>;

and then use this in the add instruction pattern:

  defm AR : BinaryRRAndK<"ar", 0x1A, 0xB9F8, z_sadd, GR32, GR32>;

These SystemZ target changes are implemented here as well.


Note that PatFrag is now defined as a subclass of PatFrags, which
means that some users of internals of PatFrag need to be updated.
(E.g. instead of using PatFrag.Fragment you now need to use
!head(PatFrag.Fragments).)


The implementation is based on the following main ideas:
- InlinePatternFragments may now replace each original pattern
  with several result patterns, not just one.
- parseInstructionPattern delays calling InlinePatternFragments
  and InferAllTypes.  Instead, it extracts a single DAG match
  pattern from the main instruction pattern.
- Processing of the DAG match pattern part of the main instruction
  pattern now shares most code with processing match patterns from
  the Pattern class.
- Direct use of main instruction patterns in InferFromPattern and
  EmitResultInstructionAsOperand is removed; everything now operates
  solely on DAG match patterns.


Reviewed by: hfinkel

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

llvm-svn: 336999
2018-07-13 13:18:00 +00:00
..
ADT Reverted r336805 as it broke llvm-clang-x86_64-expensive-checks-win build bot 2018-07-12 17:58:10 +00:00
Analysis [InstSimplify] simplify add instruction if two operands are negative 2018-07-12 03:06:04 +00:00
AsmParser Fix -Wdocumentation warnings. NFCI. 2018-07-12 09:10:55 +00:00
BinaryFormat [llvm-readobj] Add experimental support for SHT_RELR sections 2018-06-28 21:07:34 +00:00
Bitcode Fix for llvm-dis/llvm-bcanalyzer overflows 2018-06-04 19:20:02 +00:00
CodeGen [SLH] Introduce a new pass to do Speculative Load Hardening to mitigate 2018-07-13 11:13:58 +00:00
Config Don't redefine a bunch of defines from llvm-config.h in config.h. 2018-05-10 14:45:05 +00:00
DebugInfo [DebugInfo] Make children iterator bidirectional 2018-07-11 17:11:11 +00:00
Demangle Move Compiler.h from Demangle back to Support 2018-06-04 22:53:38 +00:00
ExecutionEngine Fix few typos in comments (write access test commit) 2018-07-12 06:41:41 +00:00
FuzzMutate [llvm-opt-fuzzer] Avoid adding incorrect inputs to the fuzzer corpus 2018-02-05 11:05:47 +00:00
IR [DomTreeUpdater] Ignore updates when both DT and PDT are nullptrs 2018-07-13 04:02:13 +00:00
IRReader LLParser: add an argument for overriding data layout and do not check alloca addr space 2018-01-30 22:32:39 +00:00
LineEditor
Linker Remove \brief commands from doxygen comments. 2018-05-01 15:54:18 +00:00
LTO IRGen: Write .dwo files when -split-dwarf-file is used together with -fthinlto-index. 2018-05-31 18:25:59 +00:00
MC [DWARF v5] Generate range list tables into the .debug_rnglists section. No support for split DWARF 2018-07-12 18:18:21 +00:00
Object [llvm-readobj] Add -hex-dump (-x) option 2018-07-11 10:00:29 +00:00
ObjectYAML Resubmit [pdb] Change /DEBUG:GHASH to emit 8 byte hashes." 2018-05-17 22:55:15 +00:00
Option [Option] Remove an unnecessary conversion function. 2018-05-05 06:05:31 +00:00
Passes Fix build warning compiling TestPlugin on Windows and disable Passes plugin stuff on Windows since it fundamentally can't work 2018-05-19 03:05:30 +00:00
ProfileData [NFC] Change sample profile format enum name SPF_Raw_Binary to SPF_Binary. 2018-06-12 05:53:49 +00:00
Support [Support] Require llvm::Error passed to formatv() to be wrapped in fmt_consume() 2018-07-12 07:11:28 +00:00
TableGen [TableGen] Add a general-purpose JSON backend. 2018-07-11 08:40:19 +00:00
Target [TableGen] Support multi-alternative pattern fragments 2018-07-13 13:18:00 +00:00
Testing/Support [Testing/Support] Make Failed() matcher work with abstract error types 2018-04-10 14:11:53 +00:00
ToolDrivers
Transforms [ThinLTO] Use std::map to get determistic imports files 2018-07-10 20:06:04 +00:00
WindowsManifest
WindowsResource
XRay [XRay][compiler-rt] Add PID field to llvm-xray tool and add PID metadata record entry in FDR mode 2018-07-13 05:38:22 +00:00
CMakeLists.txt
InitializePasses.h [UnrollAndJam] New Unroll and Jam pass 2018-07-01 12:47:30 +00:00
LinkAllIR.h
LinkAllPasses.h [UnrollAndJam] New Unroll and Jam pass 2018-07-01 12:47:30 +00:00
module.modulemap Reappl "[Dominators] Add the DomTreeUpdater class" 2018-07-03 02:06:23 +00:00
module.modulemap.build
Pass.h Remove @brief commands from doxygen comments, too. 2018-05-01 16:10:38 +00:00
PassAnalysisSupport.h [NFC] fix trivial typos in comments 2018-01-23 05:49:30 +00:00
PassInfo.h
PassRegistry.h
PassSupport.h