2011-10-01 18:41:13 +02:00
|
|
|
//===- TableGen.cpp - Top-Level TableGen implementation for LLVM ----------===//
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2003-10-20 22:20:30 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 21:37:13 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 02:00:37 +02:00
|
|
|
//
|
2003-10-20 22:20:30 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2003-10-05 21:27:59 +02:00
|
|
|
//
|
2011-10-01 18:41:13 +02:00
|
|
|
// This file contains the main function for LLVM's TableGen.
|
2003-10-05 21:27:59 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-06-11 17:37:55 +02:00
|
|
|
#include "TableGenBackends.h" // Declares all backends.
|
2009-07-08 20:44:05 +02:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2016-01-04 05:51:51 +01:00
|
|
|
#include "llvm/Support/ManagedStatic.h"
|
2009-07-08 20:44:05 +02:00
|
|
|
#include "llvm/Support/PrettyStackTrace.h"
|
2010-11-29 19:16:10 +01:00
|
|
|
#include "llvm/Support/Signals.h"
|
2011-10-01 18:41:13 +02:00
|
|
|
#include "llvm/TableGen/Main.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
2014-06-17 15:10:38 +02:00
|
|
|
#include "llvm/TableGen/SetTheory.h"
|
2011-10-01 18:41:13 +02:00
|
|
|
|
2004-08-01 05:55:39 +02:00
|
|
|
using namespace llvm;
|
2003-11-11 23:41:34 +01:00
|
|
|
|
2003-10-05 21:27:59 +02:00
|
|
|
enum ActionType {
|
|
|
|
PrintRecords,
|
[TableGen] Add a general-purpose JSON backend.
The aim of this backend is to output everything TableGen knows about
the record set, similarly to the default -print-records backend. But
where -print-records produces output in TableGen's input syntax
(convenient for humans to read), this backend produces it as
structured JSON data, which is convenient for loading into standard
scripting languages such as Python, in order to extract information
from the data set in an automated way.
The output data contains a JSON representation of the variable
definitions in output 'def' records, and a few pieces of metadata such
as which of those definitions are tagged with the 'field' prefix and
which defs are derived from which classes. It doesn't dump out
absolutely every piece of knowledge it _could_ produce, such as type
information and complicated arithmetic operator nodes in abstract
superclasses; the main aim is to allow consumers of this JSON dump to
essentially act as new backends, and backends don't generally need to
depend on that kind of data.
The new backend is implemented as an EmitJSON() function similar to
all of llvm-tblgen's other EmitFoo functions, except that it lives in
lib/TableGen instead of utils/TableGen on the basis that I'm expecting
to add it to clang-tblgen too in a future patch.
To test it, I've written a Python script that loads the JSON output
and tests properties of it based on comments in the .td source - more
or less like FileCheck, except that the CHECK: lines have Python
expressions after them instead of textual pattern matches.
Reviewers: nhaehnle
Reviewed By: nhaehnle
Subscribers: arichardson, labath, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D46054
llvm-svn: 336771
2018-07-11 10:40:19 +02:00
|
|
|
DumpJSON,
|
2003-10-05 21:27:59 +02:00
|
|
|
GenEmitter,
|
2011-06-27 20:32:37 +02:00
|
|
|
GenRegisterInfo,
|
2011-06-28 22:07:07 +02:00
|
|
|
GenInstrInfo,
|
2017-11-14 16:35:15 +01:00
|
|
|
GenInstrDocs,
|
2011-06-28 22:07:07 +02:00
|
|
|
GenAsmWriter,
|
|
|
|
GenAsmMatcher,
|
2009-11-25 03:13:23 +01:00
|
|
|
GenDisassembler,
|
2011-07-08 19:36:35 +02:00
|
|
|
GenPseudoLowering,
|
[RISCV] Tablegen-driven Instruction Compression.
Summary:
This patch implements a tablegen-driven Instruction Compression
mechanism for generating RISCV compressed instructions
(C Extension) from the expanded instruction form.
This tablegen backend processes CompressPat declarations in a
td file and generates all the compile-time and runtime checks
required to validate the declarations, validate the input
operands and generate correct instructions.
The checks include validating register operands, immediate
operands, fixed register operands and fixed immediate operands.
Example:
class CompressPat<dag input, dag output> {
dag Input = input;
dag Output = output;
list<Predicate> Predicates = [];
}
let Predicates = [HasStdExtC] in {
def : CompressPat<(ADD GPRNoX0:$rs1, GPRNoX0:$rs1, GPRNoX0:$rs2),
(C_ADD GPRNoX0:$rs1, GPRNoX0:$rs2)>;
}
The result is an auto-generated header file
'RISCVGenCompressEmitter.inc' which exports two functions for
compressing/uncompressing MCInst instructions, plus
some helper functions:
bool compressInst(MCInst& OutInst, const MCInst &MI,
const MCSubtargetInfo &STI,
MCContext &Context);
bool uncompressInst(MCInst& OutInst, const MCInst &MI,
const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI);
The clients that include this auto-generated header file and
invoke these functions can compress an instruction before emitting
it, in the target-specific ASM or ELF streamer, or can uncompress
an instruction before printing it, when the expanded instruction
format aliases is favored.
The following clients were added to implement compression\uncompression
for RISCV:
1) RISCVAsmParser::MatchAndEmitInstruction:
Inserted a call to compressInst() to compresses instructions
parsed by llvm-mc coming from an ASM input.
2) RISCVAsmPrinter::EmitInstruction:
Inserted a call to compressInst() to compress instructions that
were lowered from Machine Instructions (MachineInstr).
3) RVInstPrinter::printInst:
Inserted a call to uncompressInst() to print the expanded
version of the instruction instead of the compressed one (e.g,
add s0, s0, a5 instead of c.add s0, a5) when -riscv-no-aliases
is not passed.
This patch squashes D45119, D42780 and D41932. It was reviewed in smaller patches by
asb, efriedma, apazos and mgrang.
Reviewers: asb, efriedma, apazos, llvm-commits, sabuasal
Reviewed By: sabuasal
Subscribers: mgorny, eraman, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, niosHD, kito-cheng, shiva0217, zzheng
Differential Revision: https://reviews.llvm.org/D45385
llvm-svn: 329455
2018-04-06 23:07:05 +02:00
|
|
|
GenCompressInst,
|
2007-02-27 23:08:27 +01:00
|
|
|
GenCallingConv,
|
2005-09-03 03:14:03 +02:00
|
|
|
GenDAGISel,
|
2011-12-01 22:10:21 +01:00
|
|
|
GenDFAPacketizer,
|
2008-08-13 22:19:35 +02:00
|
|
|
GenFastISel,
|
2005-10-21 21:05:19 +02:00
|
|
|
GenSubtarget,
|
2018-06-23 04:02:38 +02:00
|
|
|
GenIntrinsicEnums,
|
|
|
|
GenIntrinsicImpl,
|
|
|
|
GenTgtIntrinsicEnums,
|
|
|
|
GenTgtIntrinsicImpl,
|
2011-06-04 06:11:37 +02:00
|
|
|
PrintEnums,
|
2012-12-05 01:29:32 +01:00
|
|
|
PrintSets,
|
2013-03-22 00:40:38 +01:00
|
|
|
GenOptParserDefs,
|
2015-11-11 21:35:42 +01:00
|
|
|
GenCTags,
|
2016-07-05 23:23:04 +02:00
|
|
|
GenAttributes,
|
|
|
|
GenSearchableTables,
|
2016-12-22 00:26:20 +01:00
|
|
|
GenGlobalISel,
|
2017-03-07 09:11:19 +01:00
|
|
|
GenX86EVEX2VEXTables,
|
2017-10-08 11:20:32 +02:00
|
|
|
GenX86FoldTables,
|
Re-commit: [globalisel] Tablegen-erate current Register Bank Information
Summary:
Adds a RegisterBank tablegen class that can be used to declare the register
banks and an associated tablegen pass to generate the necessary code.
Changes since first commit attempt:
* Added missing guards
* Added more missing guards
* Found and fixed a use-after-free bug involving Twine locals
Reviewers: t.p.northover, ab, rovka, qcolombet
Reviewed By: qcolombet
Subscribers: aditya_nandakumar, rengolin, kristof.beyls, vkalintiris, mgorny, dberris, llvm-commits, rovka
Differential Revision: https://reviews.llvm.org/D27338
llvm-svn: 292478
2017-01-19 12:15:55 +01:00
|
|
|
GenRegisterBank,
|
2018-10-25 09:44:01 +02:00
|
|
|
GenExegesis,
|
2003-10-05 21:27:59 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
cl::opt<ActionType>
|
|
|
|
Action(cl::desc("Action to perform:"),
|
|
|
|
cl::values(clEnumValN(PrintRecords, "print-records",
|
|
|
|
"Print all records to stdout (default)"),
|
[TableGen] Add a general-purpose JSON backend.
The aim of this backend is to output everything TableGen knows about
the record set, similarly to the default -print-records backend. But
where -print-records produces output in TableGen's input syntax
(convenient for humans to read), this backend produces it as
structured JSON data, which is convenient for loading into standard
scripting languages such as Python, in order to extract information
from the data set in an automated way.
The output data contains a JSON representation of the variable
definitions in output 'def' records, and a few pieces of metadata such
as which of those definitions are tagged with the 'field' prefix and
which defs are derived from which classes. It doesn't dump out
absolutely every piece of knowledge it _could_ produce, such as type
information and complicated arithmetic operator nodes in abstract
superclasses; the main aim is to allow consumers of this JSON dump to
essentially act as new backends, and backends don't generally need to
depend on that kind of data.
The new backend is implemented as an EmitJSON() function similar to
all of llvm-tblgen's other EmitFoo functions, except that it lives in
lib/TableGen instead of utils/TableGen on the basis that I'm expecting
to add it to clang-tblgen too in a future patch.
To test it, I've written a Python script that loads the JSON output
and tests properties of it based on comments in the .td source - more
or less like FileCheck, except that the CHECK: lines have Python
expressions after them instead of textual pattern matches.
Reviewers: nhaehnle
Reviewed By: nhaehnle
Subscribers: arichardson, labath, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D46054
llvm-svn: 336771
2018-07-11 10:40:19 +02:00
|
|
|
clEnumValN(DumpJSON, "dump-json",
|
|
|
|
"Dump all records as machine-readable JSON"),
|
2003-10-05 21:27:59 +02:00
|
|
|
clEnumValN(GenEmitter, "gen-emitter",
|
|
|
|
"Generate machine code emitter"),
|
2011-06-24 03:44:41 +02:00
|
|
|
clEnumValN(GenRegisterInfo, "gen-register-info",
|
2011-06-27 20:32:37 +02:00
|
|
|
"Generate registers and register classes info"),
|
2011-06-28 22:07:07 +02:00
|
|
|
clEnumValN(GenInstrInfo, "gen-instr-info",
|
2003-10-05 21:27:59 +02:00
|
|
|
"Generate instruction descriptions"),
|
2017-11-14 16:35:15 +01:00
|
|
|
clEnumValN(GenInstrDocs, "gen-instr-docs",
|
|
|
|
"Generate instruction documentation"),
|
2007-02-27 23:08:27 +01:00
|
|
|
clEnumValN(GenCallingConv, "gen-callingconv",
|
|
|
|
"Generate calling convention descriptions"),
|
2004-08-01 07:59:33 +02:00
|
|
|
clEnumValN(GenAsmWriter, "gen-asm-writer",
|
|
|
|
"Generate assembly writer"),
|
2009-11-25 03:13:23 +01:00
|
|
|
clEnumValN(GenDisassembler, "gen-disassembler",
|
|
|
|
"Generate disassembler"),
|
2011-07-08 19:36:35 +02:00
|
|
|
clEnumValN(GenPseudoLowering, "gen-pseudo-lowering",
|
|
|
|
"Generate pseudo instruction lowering"),
|
[RISCV] Tablegen-driven Instruction Compression.
Summary:
This patch implements a tablegen-driven Instruction Compression
mechanism for generating RISCV compressed instructions
(C Extension) from the expanded instruction form.
This tablegen backend processes CompressPat declarations in a
td file and generates all the compile-time and runtime checks
required to validate the declarations, validate the input
operands and generate correct instructions.
The checks include validating register operands, immediate
operands, fixed register operands and fixed immediate operands.
Example:
class CompressPat<dag input, dag output> {
dag Input = input;
dag Output = output;
list<Predicate> Predicates = [];
}
let Predicates = [HasStdExtC] in {
def : CompressPat<(ADD GPRNoX0:$rs1, GPRNoX0:$rs1, GPRNoX0:$rs2),
(C_ADD GPRNoX0:$rs1, GPRNoX0:$rs2)>;
}
The result is an auto-generated header file
'RISCVGenCompressEmitter.inc' which exports two functions for
compressing/uncompressing MCInst instructions, plus
some helper functions:
bool compressInst(MCInst& OutInst, const MCInst &MI,
const MCSubtargetInfo &STI,
MCContext &Context);
bool uncompressInst(MCInst& OutInst, const MCInst &MI,
const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI);
The clients that include this auto-generated header file and
invoke these functions can compress an instruction before emitting
it, in the target-specific ASM or ELF streamer, or can uncompress
an instruction before printing it, when the expanded instruction
format aliases is favored.
The following clients were added to implement compression\uncompression
for RISCV:
1) RISCVAsmParser::MatchAndEmitInstruction:
Inserted a call to compressInst() to compresses instructions
parsed by llvm-mc coming from an ASM input.
2) RISCVAsmPrinter::EmitInstruction:
Inserted a call to compressInst() to compress instructions that
were lowered from Machine Instructions (MachineInstr).
3) RVInstPrinter::printInst:
Inserted a call to uncompressInst() to print the expanded
version of the instruction instead of the compressed one (e.g,
add s0, s0, a5 instead of c.add s0, a5) when -riscv-no-aliases
is not passed.
This patch squashes D45119, D42780 and D41932. It was reviewed in smaller patches by
asb, efriedma, apazos and mgrang.
Reviewers: asb, efriedma, apazos, llvm-commits, sabuasal
Reviewed By: sabuasal
Subscribers: mgorny, eraman, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, niosHD, kito-cheng, shiva0217, zzheng
Differential Revision: https://reviews.llvm.org/D45385
llvm-svn: 329455
2018-04-06 23:07:05 +02:00
|
|
|
clEnumValN(GenCompressInst, "gen-compress-inst-emitter",
|
|
|
|
"Generate RISCV compressed instructions."),
|
2009-07-11 21:39:44 +02:00
|
|
|
clEnumValN(GenAsmMatcher, "gen-asm-matcher",
|
|
|
|
"Generate assembly instruction matcher"),
|
2005-09-03 03:14:03 +02:00
|
|
|
clEnumValN(GenDAGISel, "gen-dag-isel",
|
|
|
|
"Generate a DAG instruction selector"),
|
2011-12-01 22:10:21 +01:00
|
|
|
clEnumValN(GenDFAPacketizer, "gen-dfa-packetizer",
|
|
|
|
"Generate DFA Packetizer for VLIW targets"),
|
2008-08-13 22:19:35 +02:00
|
|
|
clEnumValN(GenFastISel, "gen-fast-isel",
|
|
|
|
"Generate a \"fast\" instruction selector"),
|
2005-10-21 21:05:19 +02:00
|
|
|
clEnumValN(GenSubtarget, "gen-subtarget",
|
|
|
|
"Generate subtarget enumerations"),
|
2018-06-23 04:02:38 +02:00
|
|
|
clEnumValN(GenIntrinsicEnums, "gen-intrinsic-enums",
|
|
|
|
"Generate intrinsic enums"),
|
|
|
|
clEnumValN(GenIntrinsicImpl, "gen-intrinsic-impl",
|
2006-03-03 03:32:46 +01:00
|
|
|
"Generate intrinsic information"),
|
2018-06-23 04:02:38 +02:00
|
|
|
clEnumValN(GenTgtIntrinsicEnums, "gen-tgt-intrinsic-enums",
|
|
|
|
"Generate target intrinsic enums"),
|
|
|
|
clEnumValN(GenTgtIntrinsicImpl, "gen-tgt-intrinsic-impl",
|
2009-02-05 02:49:45 +01:00
|
|
|
"Generate target intrinsic information"),
|
2003-10-05 21:27:59 +02:00
|
|
|
clEnumValN(PrintEnums, "print-enums",
|
|
|
|
"Print enum values for a class"),
|
2011-06-04 06:11:37 +02:00
|
|
|
clEnumValN(PrintSets, "print-sets",
|
|
|
|
"Print expanded sets for testing DAG exprs"),
|
2012-12-05 01:29:32 +01:00
|
|
|
clEnumValN(GenOptParserDefs, "gen-opt-parser-defs",
|
|
|
|
"Generate option definitions"),
|
2013-03-22 00:40:38 +01:00
|
|
|
clEnumValN(GenCTags, "gen-ctags",
|
|
|
|
"Generate ctags-compatible index"),
|
2015-11-11 21:35:42 +01:00
|
|
|
clEnumValN(GenAttributes, "gen-attrs",
|
|
|
|
"Generate attributes"),
|
2016-07-05 23:23:04 +02:00
|
|
|
clEnumValN(GenSearchableTables, "gen-searchable-tables",
|
2016-12-22 00:26:20 +01:00
|
|
|
"Generate generic binary-searchable table"),
|
|
|
|
clEnumValN(GenGlobalISel, "gen-global-isel",
|
Re-commit: [globalisel] Tablegen-erate current Register Bank Information
Summary:
Adds a RegisterBank tablegen class that can be used to declare the register
banks and an associated tablegen pass to generate the necessary code.
Changes since first commit attempt:
* Added missing guards
* Added more missing guards
* Found and fixed a use-after-free bug involving Twine locals
Reviewers: t.p.northover, ab, rovka, qcolombet
Reviewed By: qcolombet
Subscribers: aditya_nandakumar, rengolin, kristof.beyls, vkalintiris, mgorny, dberris, llvm-commits, rovka
Differential Revision: https://reviews.llvm.org/D27338
llvm-svn: 292478
2017-01-19 12:15:55 +01:00
|
|
|
"Generate GlobalISel selector"),
|
2017-03-07 09:11:19 +01:00
|
|
|
clEnumValN(GenX86EVEX2VEXTables, "gen-x86-EVEX2VEX-tables",
|
|
|
|
"Generate X86 EVEX to VEX compress tables"),
|
2017-10-08 11:20:32 +02:00
|
|
|
clEnumValN(GenX86FoldTables, "gen-x86-fold-tables",
|
|
|
|
"Generate X86 fold tables"),
|
Re-commit: [globalisel] Tablegen-erate current Register Bank Information
Summary:
Adds a RegisterBank tablegen class that can be used to declare the register
banks and an associated tablegen pass to generate the necessary code.
Changes since first commit attempt:
* Added missing guards
* Added more missing guards
* Found and fixed a use-after-free bug involving Twine locals
Reviewers: t.p.northover, ab, rovka, qcolombet
Reviewed By: qcolombet
Subscribers: aditya_nandakumar, rengolin, kristof.beyls, vkalintiris, mgorny, dberris, llvm-commits, rovka
Differential Revision: https://reviews.llvm.org/D27338
llvm-svn: 292478
2017-01-19 12:15:55 +01:00
|
|
|
clEnumValN(GenRegisterBank, "gen-register-bank",
|
2018-10-25 09:44:01 +02:00
|
|
|
"Generate registers bank descriptions"),
|
|
|
|
clEnumValN(GenExegesis, "gen-exegesis",
|
|
|
|
"Generate llvm-exegesis tables")));
|
2003-10-05 21:27:59 +02:00
|
|
|
|
2017-03-27 15:15:13 +02:00
|
|
|
cl::OptionCategory PrintEnumsCat("Options for -print-enums");
|
2003-10-05 21:27:59 +02:00
|
|
|
cl::opt<std::string>
|
|
|
|
Class("class", cl::desc("Print Enum list for this class"),
|
2017-03-27 15:15:13 +02:00
|
|
|
cl::value_desc("class name"), cl::cat(PrintEnumsCat));
|
2012-06-11 17:37:55 +02:00
|
|
|
|
2012-10-03 23:29:19 +02:00
|
|
|
bool LLVMTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
|
|
|
|
switch (Action) {
|
|
|
|
case PrintRecords:
|
|
|
|
OS << Records; // No argument, dump all contents
|
|
|
|
break;
|
[TableGen] Add a general-purpose JSON backend.
The aim of this backend is to output everything TableGen knows about
the record set, similarly to the default -print-records backend. But
where -print-records produces output in TableGen's input syntax
(convenient for humans to read), this backend produces it as
structured JSON data, which is convenient for loading into standard
scripting languages such as Python, in order to extract information
from the data set in an automated way.
The output data contains a JSON representation of the variable
definitions in output 'def' records, and a few pieces of metadata such
as which of those definitions are tagged with the 'field' prefix and
which defs are derived from which classes. It doesn't dump out
absolutely every piece of knowledge it _could_ produce, such as type
information and complicated arithmetic operator nodes in abstract
superclasses; the main aim is to allow consumers of this JSON dump to
essentially act as new backends, and backends don't generally need to
depend on that kind of data.
The new backend is implemented as an EmitJSON() function similar to
all of llvm-tblgen's other EmitFoo functions, except that it lives in
lib/TableGen instead of utils/TableGen on the basis that I'm expecting
to add it to clang-tblgen too in a future patch.
To test it, I've written a Python script that loads the JSON output
and tests properties of it based on comments in the .td source - more
or less like FileCheck, except that the CHECK: lines have Python
expressions after them instead of textual pattern matches.
Reviewers: nhaehnle
Reviewed By: nhaehnle
Subscribers: arichardson, labath, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D46054
llvm-svn: 336771
2018-07-11 10:40:19 +02:00
|
|
|
case DumpJSON:
|
|
|
|
EmitJSON(Records, OS);
|
|
|
|
break;
|
2012-10-03 23:29:19 +02:00
|
|
|
case GenEmitter:
|
|
|
|
EmitCodeEmitter(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenRegisterInfo:
|
|
|
|
EmitRegisterInfo(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenInstrInfo:
|
|
|
|
EmitInstrInfo(Records, OS);
|
|
|
|
break;
|
2017-11-14 16:35:15 +01:00
|
|
|
case GenInstrDocs:
|
|
|
|
EmitInstrDocs(Records, OS);
|
|
|
|
break;
|
2012-10-03 23:29:19 +02:00
|
|
|
case GenCallingConv:
|
|
|
|
EmitCallingConv(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenAsmWriter:
|
|
|
|
EmitAsmWriter(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenAsmMatcher:
|
|
|
|
EmitAsmMatcher(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenDisassembler:
|
|
|
|
EmitDisassembler(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenPseudoLowering:
|
|
|
|
EmitPseudoLowering(Records, OS);
|
|
|
|
break;
|
[RISCV] Tablegen-driven Instruction Compression.
Summary:
This patch implements a tablegen-driven Instruction Compression
mechanism for generating RISCV compressed instructions
(C Extension) from the expanded instruction form.
This tablegen backend processes CompressPat declarations in a
td file and generates all the compile-time and runtime checks
required to validate the declarations, validate the input
operands and generate correct instructions.
The checks include validating register operands, immediate
operands, fixed register operands and fixed immediate operands.
Example:
class CompressPat<dag input, dag output> {
dag Input = input;
dag Output = output;
list<Predicate> Predicates = [];
}
let Predicates = [HasStdExtC] in {
def : CompressPat<(ADD GPRNoX0:$rs1, GPRNoX0:$rs1, GPRNoX0:$rs2),
(C_ADD GPRNoX0:$rs1, GPRNoX0:$rs2)>;
}
The result is an auto-generated header file
'RISCVGenCompressEmitter.inc' which exports two functions for
compressing/uncompressing MCInst instructions, plus
some helper functions:
bool compressInst(MCInst& OutInst, const MCInst &MI,
const MCSubtargetInfo &STI,
MCContext &Context);
bool uncompressInst(MCInst& OutInst, const MCInst &MI,
const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI);
The clients that include this auto-generated header file and
invoke these functions can compress an instruction before emitting
it, in the target-specific ASM or ELF streamer, or can uncompress
an instruction before printing it, when the expanded instruction
format aliases is favored.
The following clients were added to implement compression\uncompression
for RISCV:
1) RISCVAsmParser::MatchAndEmitInstruction:
Inserted a call to compressInst() to compresses instructions
parsed by llvm-mc coming from an ASM input.
2) RISCVAsmPrinter::EmitInstruction:
Inserted a call to compressInst() to compress instructions that
were lowered from Machine Instructions (MachineInstr).
3) RVInstPrinter::printInst:
Inserted a call to uncompressInst() to print the expanded
version of the instruction instead of the compressed one (e.g,
add s0, s0, a5 instead of c.add s0, a5) when -riscv-no-aliases
is not passed.
This patch squashes D45119, D42780 and D41932. It was reviewed in smaller patches by
asb, efriedma, apazos and mgrang.
Reviewers: asb, efriedma, apazos, llvm-commits, sabuasal
Reviewed By: sabuasal
Subscribers: mgorny, eraman, asb, rbar, johnrusso, simoncook, jordy.potman.lists, apazos, niosHD, kito-cheng, shiva0217, zzheng
Differential Revision: https://reviews.llvm.org/D45385
llvm-svn: 329455
2018-04-06 23:07:05 +02:00
|
|
|
case GenCompressInst:
|
|
|
|
EmitCompressInst(Records, OS);
|
|
|
|
break;
|
2012-10-03 23:29:19 +02:00
|
|
|
case GenDAGISel:
|
|
|
|
EmitDAGISel(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenDFAPacketizer:
|
|
|
|
EmitDFAPacketizer(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenFastISel:
|
|
|
|
EmitFastISel(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenSubtarget:
|
|
|
|
EmitSubtarget(Records, OS);
|
|
|
|
break;
|
2018-06-23 04:02:38 +02:00
|
|
|
case GenIntrinsicEnums:
|
|
|
|
EmitIntrinsicEnums(Records, OS);
|
2012-10-03 23:29:19 +02:00
|
|
|
break;
|
2018-06-23 04:02:38 +02:00
|
|
|
case GenIntrinsicImpl:
|
|
|
|
EmitIntrinsicImpl(Records, OS);
|
|
|
|
break;
|
|
|
|
case GenTgtIntrinsicEnums:
|
|
|
|
EmitIntrinsicEnums(Records, OS, true);
|
|
|
|
break;
|
|
|
|
case GenTgtIntrinsicImpl:
|
|
|
|
EmitIntrinsicImpl(Records, OS, true);
|
2012-10-03 23:29:19 +02:00
|
|
|
break;
|
2012-12-05 01:29:32 +01:00
|
|
|
case GenOptParserDefs:
|
|
|
|
EmitOptParser(Records, OS);
|
|
|
|
break;
|
2012-10-03 23:29:19 +02:00
|
|
|
case PrintEnums:
|
|
|
|
{
|
2014-12-11 08:04:54 +01:00
|
|
|
for (Record *Rec : Records.getAllDerivedDefinitions(Class))
|
|
|
|
OS << Rec->getName() << ", ";
|
2012-10-03 23:29:19 +02:00
|
|
|
OS << "\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case PrintSets:
|
|
|
|
{
|
|
|
|
SetTheory Sets;
|
|
|
|
Sets.addFieldExpander("Set", "Elements");
|
2014-12-11 08:04:54 +01:00
|
|
|
for (Record *Rec : Records.getAllDerivedDefinitions("Set")) {
|
|
|
|
OS << Rec->getName() << " = [";
|
|
|
|
const std::vector<Record*> *Elts = Sets.expand(Rec);
|
2012-10-03 23:29:19 +02:00
|
|
|
assert(Elts && "Couldn't expand Set instance");
|
2014-12-11 08:04:54 +01:00
|
|
|
for (Record *Elt : *Elts)
|
|
|
|
OS << ' ' << Elt->getName();
|
2012-10-03 23:29:19 +02:00
|
|
|
OS << " ]\n";
|
2003-11-11 23:41:34 +01:00
|
|
|
}
|
2012-10-03 23:29:19 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-03-22 00:40:38 +01:00
|
|
|
case GenCTags:
|
|
|
|
EmitCTags(Records, OS);
|
|
|
|
break;
|
2015-11-11 21:35:42 +01:00
|
|
|
case GenAttributes:
|
|
|
|
EmitAttributes(Records, OS);
|
|
|
|
break;
|
2016-07-05 23:23:04 +02:00
|
|
|
case GenSearchableTables:
|
|
|
|
EmitSearchableTables(Records, OS);
|
|
|
|
break;
|
2016-12-22 00:26:20 +01:00
|
|
|
case GenGlobalISel:
|
|
|
|
EmitGlobalISel(Records, OS);
|
2017-02-03 15:18:35 +01:00
|
|
|
break;
|
Re-commit: [globalisel] Tablegen-erate current Register Bank Information
Summary:
Adds a RegisterBank tablegen class that can be used to declare the register
banks and an associated tablegen pass to generate the necessary code.
Changes since first commit attempt:
* Added missing guards
* Added more missing guards
* Found and fixed a use-after-free bug involving Twine locals
Reviewers: t.p.northover, ab, rovka, qcolombet
Reviewed By: qcolombet
Subscribers: aditya_nandakumar, rengolin, kristof.beyls, vkalintiris, mgorny, dberris, llvm-commits, rovka
Differential Revision: https://reviews.llvm.org/D27338
llvm-svn: 292478
2017-01-19 12:15:55 +01:00
|
|
|
case GenRegisterBank:
|
|
|
|
EmitRegisterBank(Records, OS);
|
2016-12-22 00:26:20 +01:00
|
|
|
break;
|
2017-03-07 09:11:19 +01:00
|
|
|
case GenX86EVEX2VEXTables:
|
|
|
|
EmitX86EVEX2VEXTables(Records, OS);
|
|
|
|
break;
|
2017-10-08 11:20:32 +02:00
|
|
|
case GenX86FoldTables:
|
|
|
|
EmitX86FoldTables(Records, OS);
|
|
|
|
break;
|
2018-10-25 09:44:01 +02:00
|
|
|
case GenExegesis:
|
|
|
|
EmitExegesis(Records, OS);
|
|
|
|
break;
|
2012-10-03 23:29:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-20 03:50:00 +01:00
|
|
|
}
|
2011-10-01 18:41:13 +02:00
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2016-06-09 02:53:21 +02:00
|
|
|
sys::PrintStackTraceOnErrorSignal(argv[0]);
|
2011-10-01 18:41:13 +02:00
|
|
|
PrettyStackTraceProgram X(argc, argv);
|
|
|
|
cl::ParseCommandLineOptions(argc, argv);
|
2010-05-05 06:13:08 +02:00
|
|
|
|
2016-01-04 05:51:51 +01:00
|
|
|
llvm_shutdown_obj Y;
|
|
|
|
|
2012-10-03 23:29:19 +02:00
|
|
|
return TableGenMain(argv[0], &LLVMTableGenMain);
|
2003-10-05 21:27:59 +02:00
|
|
|
}
|
2014-01-10 09:05:42 +01:00
|
|
|
|
2014-01-15 08:59:37 +01:00
|
|
|
#ifdef __has_feature
|
|
|
|
#if __has_feature(address_sanitizer)
|
|
|
|
#include <sanitizer/lsan_interface.h>
|
2014-01-10 09:05:42 +01:00
|
|
|
// Disable LeakSanitizer for this binary as it has too many leaks that are not
|
2014-01-15 08:59:37 +01:00
|
|
|
// very interesting to fix. See compiler-rt/include/sanitizer/lsan_interface.h .
|
2017-09-11 15:50:39 +02:00
|
|
|
LLVM_ATTRIBUTE_USED int __lsan_is_turned_off() { return 1; }
|
2014-01-15 08:59:37 +01:00
|
|
|
#endif // __has_feature(address_sanitizer)
|
|
|
|
#endif // defined(__has_feature)
|