Table of Contents
- 1. TableGen Introduction
- 2. Type, Value, Class, Field, Definition, Name:
- 3. TableGen Pattern Syntax:
1 TableGen Introduction
- TableGen source file contain two primary items:
- abstract record (class)
- concrete record (record in short)
- Class and concrete record have a unique name.
- Associate with that name is a list of fields with values and an optional list of superclasses.
- The fields are the primary data that backends will process.
- Classes are used to abstract out groups of record fields.
- TableGen allows an arbitrary hierarchy of classes, so that the abstract classes for two concepts can share a third superclass that abstracts common ‘sub-concepts’ from the two original concepts.
- Template Arguments to class.
- Both classes and concrete records can include fields that are uninitialized. The uninitialized “value” is represented by a question mark (?) .
- Multiclass
2 Type, Value, Class, Field, Definition, Name:
- Definition (Concrete Record) is declared by ‘def’.
- Class (Abstract Record) is declared by ‘class’.
- Fields are the primary data for records.
- Class can accept Template arguments to be parameterised.
- Some fields can be uninitialized and filled in later on.
- Every Value is required to have an associated type.
- Type :: = “bit” | “int” | “string” | “dag” | “bits” “<” TokInteger “>” | “list” “<” Type “>” | ClassID
3 TableGen Pattern Syntax:
-
Pattern:
Pat<(SDPatternOperator DAGOperand:$name1, DAGOperand:$name2, ...) , (Instrunction DAGOperand:$name1, DAGOperand:$name2, ...) >;
class Pat<dag pattern, dag result> : Pattern<pattern, [result]>; class Pattern<dag patternToMatch, list<dag> resultInstrs> { dag PatternToMatch = patternToMatch; list<dag> ResultInstrs = resultInstrs; list<Predicate> Predicates = []; // See class Instruction in Target.td. int AddedComplexity = 0; // See class Instruction in Target.td. }
-
SDPatternOperator:
class SDNode<string opcode, SDTypeProfile typeprof, list<SDNodeProperty> props = [], string sdclass = "SDNode"> : SDPatternOperator; class Intrinsic<list<LLVMType> ret_types, list<LLVMType> param_types = [], list<IntrinsicProperty> intr_properties = [], string name = "", list<SDNodeProperty> sd_properties = []> : SDPatternOperator ; class PatFrags<dag ops, list<dag> frags, code pred = [{}], SDNodeXForm xform = NOOP_SDNodeXForm> : SDPatternOperator;
-
DAGOperand: (Operand should have a type implicitly or explicitly)
class Operand<ValueType ty> : DAGOperand; class RegisterClass<string namespace, list<ValueType> regTypes, int alignment, dag regList, RegAltNameIndex idx = NoRegAltName> : DAGOperand ; class RegisterOperand<RegisterClass regclass, string pm = "printOperand">: DAGOperand;
-
Instruction:
class Instruction : InstructionEncoding;
-
Misc:
// Special TableGen-recognized dag nodes def set; def implicit; def node; def srcvalue;