mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
f2f87b751f
Summary: This is essentially a rewrite of the backend which introduces TableGen base classes GenericEnum, GenericTable, and SearchIndex. They allow generating custom enums and tables with lookup functions using separately defined records as the underlying database. Also added as part of this change: - Lookup functions may use indices composed of multiple fields. - Instruction fields are supported similar to Intrinsic fields. - When the lookup key has contiguous numeric values, the lookup function will directly index into the table instead of using a binary search. The existing SearchableTable functionality is internally mapped to the new primitives. Change-Id: I444f3490fa1dbfb262d7286a1660a2c4308e9932 Reviewers: arsenm, tra, t.p.northover Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D48013 llvm-svn: 335225
37 lines
798 B
TableGen
37 lines
798 B
TableGen
// RUN: llvm-tblgen -gen-searchable-tables -I %p/../../include %s | FileCheck %s
|
|
// XFAIL: vg_leak
|
|
|
|
include "llvm/TableGen/SearchableTable.td"
|
|
|
|
// CHECK-LABEL: GET_InstrTable_IMPL
|
|
// CHECK: const MyInstr InstrTable[] = {
|
|
// CHECK: { B, 0xA },
|
|
// CHECK: { C, 0x0 },
|
|
// CHECK: { A, 0x5 },
|
|
// CHECK: { D, 0x8 },
|
|
// CHECK: };
|
|
|
|
class Instruction {
|
|
bit isPseudo = 0;
|
|
}
|
|
|
|
class MyInstr<int op> : Instruction {
|
|
Instruction Opcode = !cast<Instruction>(NAME);
|
|
bits<16> CustomEncoding = op;
|
|
}
|
|
|
|
def A : MyInstr<5>;
|
|
def D : MyInstr<8>;
|
|
let isPseudo = 1 in {
|
|
def C : MyInstr<0>;
|
|
def B : MyInstr<10>;
|
|
}
|
|
|
|
def InstrTable : GenericTable {
|
|
let FilterClass = "MyInstr";
|
|
let Fields = ["Opcode", "CustomEncoding"];
|
|
|
|
let PrimaryKey = ["Opcode"];
|
|
let PrimaryKeyName = "getCustomEncodingHelper";
|
|
}
|