2012-06-11 23:37:55 +08:00
|
|
|
//===- TableGenBackends.h - Declarations for LLVM TableGen Backends -------===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-06-11 23:37:55 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the declarations for all of the LLVM TableGen
|
|
|
|
// backends. A "TableGen backend" is just a function. See below for a
|
|
|
|
// precise description.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
|
|
|
|
#define LLVM_UTILS_TABLEGEN_TABLEGENBACKENDS_H
|
2012-06-11 23:37:55 +08:00
|
|
|
|
|
|
|
// A TableGen backend is a function that looks like
|
|
|
|
//
|
|
|
|
// EmitFoo(RecordKeeper &RK, raw_ostream &OS /*, anything else you need */ )
|
|
|
|
//
|
|
|
|
// What you do inside of that function is up to you, but it will usually
|
|
|
|
// involve generating C++ code to the provided raw_ostream.
|
|
|
|
//
|
|
|
|
// The RecordKeeper is just a top-level container for an in-memory
|
|
|
|
// representation of the data encoded in the TableGen file. What a TableGen
|
|
|
|
// backend does is walk around that in-memory representation and generate
|
|
|
|
// stuff based on the information it contains.
|
|
|
|
//
|
|
|
|
// The in-memory representation is a node-graph (think of it like JSON but
|
|
|
|
// with a richer ontology of types), where the nodes are subclasses of
|
|
|
|
// Record. The methods `getClass`, `getDef` are the basic interface to
|
|
|
|
// access the node-graph. RecordKeeper also provides a handy method
|
|
|
|
// `getAllDerivedDefinitions`. Consult "include/llvm/TableGen/Record.h" for
|
|
|
|
// the exact interfaces provided by Record's and RecordKeeper.
|
|
|
|
//
|
|
|
|
// A common pattern for TableGen backends is for the EmitFoo function to
|
|
|
|
// instantiate a class which holds some context for the generation process,
|
|
|
|
// and then have most of the work happen in that class's methods. This
|
|
|
|
// pattern partly has historical roots in the previous TableGen backend API
|
|
|
|
// that involved a class and an invocation like `FooEmitter(RK).run(OS)`.
|
|
|
|
//
|
|
|
|
// Remember to wrap private things in an anonymous namespace. For most
|
|
|
|
// backends, this means that the EmitFoo function is the only thing not in
|
|
|
|
// the anonymous namespace.
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Reorganize TableGen so that build dependencies can be more
|
|
|
|
// accurately expressed. Currently, touching any of the emitters (or
|
|
|
|
// anything that they transitively depend on) causes everything dependent
|
|
|
|
// on TableGen to be rebuilt (this includes all the targets!). Perhaps have
|
|
|
|
// a standalone TableGen binary and have the backends be loadable modules
|
|
|
|
// of some sort; then the dependency could be expressed as being on the
|
|
|
|
// module, and all the modules would have a common dependency on the
|
|
|
|
// TableGen binary with as few dependencies as possible on the rest of
|
|
|
|
// LLVM.
|
|
|
|
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class raw_ostream;
|
|
|
|
class RecordKeeper;
|
|
|
|
|
2018-06-23 10:02:38 +08:00
|
|
|
void EmitIntrinsicEnums(RecordKeeper &RK, raw_ostream &OS,
|
|
|
|
bool TargetOnly = false);
|
|
|
|
void EmitIntrinsicImpl(RecordKeeper &RK, raw_ostream &OS,
|
|
|
|
bool TargetOnly = false);
|
2012-06-11 23:37:55 +08:00
|
|
|
void EmitAsmMatcher(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitAsmWriter(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitCallingConv(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitCodeEmitter(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitDFAPacketizer(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitDisassembler(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitFastISel(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS);
|
2017-11-14 23:35:15 +08:00
|
|
|
void EmitInstrDocs(RecordKeeper &RK, raw_ostream &OS);
|
2012-06-11 23:37:55 +08:00
|
|
|
void EmitPseudoLowering(RecordKeeper &RK, raw_ostream &OS);
|
[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-07 05:07:05 +08:00
|
|
|
void EmitCompressInst(RecordKeeper &RK, raw_ostream &OS);
|
2012-06-11 23:37:55 +08:00
|
|
|
void EmitRegisterInfo(RecordKeeper &RK, raw_ostream &OS);
|
|
|
|
void EmitSubtarget(RecordKeeper &RK, raw_ostream &OS);
|
2012-10-25 23:54:06 +08:00
|
|
|
void EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
|
2012-12-05 08:29:32 +08:00
|
|
|
void EmitOptParser(RecordKeeper &RK, raw_ostream &OS);
|
2013-03-22 07:40:38 +08:00
|
|
|
void EmitCTags(RecordKeeper &RK, raw_ostream &OS);
|
2015-11-12 04:35:42 +08:00
|
|
|
void EmitAttributes(RecordKeeper &RK, raw_ostream &OS);
|
2016-07-06 05:23:04 +08:00
|
|
|
void EmitSearchableTables(RecordKeeper &RK, raw_ostream &OS);
|
2016-12-22 07:26:20 +08:00
|
|
|
void EmitGlobalISel(RecordKeeper &RK, raw_ostream &OS);
|
2019-10-03 05:13:07 +08:00
|
|
|
void EmitGICombiner(RecordKeeper &RK, raw_ostream &OS);
|
2017-03-07 16:11:19 +08:00
|
|
|
void EmitX86EVEX2VEXTables(RecordKeeper &RK, raw_ostream &OS);
|
2017-10-08 17:20:32 +08:00
|
|
|
void EmitX86FoldTables(RecordKeeper &RK, raw_ostream &OS);
|
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 19:15:55 +08:00
|
|
|
void EmitRegisterBank(RecordKeeper &RK, raw_ostream &OS);
|
2018-10-25 15:44:01 +08:00
|
|
|
void EmitExegesis(RecordKeeper &RK, raw_ostream &OS);
|
2019-10-04 17:03:36 +08:00
|
|
|
void EmitAutomata(RecordKeeper &RK, raw_ostream &OS);
|
2012-06-11 23:37:55 +08:00
|
|
|
|
|
|
|
} // End llvm namespace
|
2014-08-14 00:26:38 +08:00
|
|
|
|
|
|
|
#endif
|