Table of Contents

  • 1. TableGen Introduction
  • 2. Type, Value, Class, Field, Definition, Name:
  • 3. TableGen Pattern Syntax:

1 TableGen Introduction

  1. TableGen source file contain two primary items:
    1. abstract record (class)
    2. concrete record (record in short)
  2. Class and concrete record have a unique name.
  3. Associate with that name is a list of fields with values and an optional list of superclasses.
  4. The fields are the primary data that backends will process.
  5. Classes are used to abstract out groups of record fields.
  6. 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.
  7. Template Arguments to class.
  8. Both classes and concrete records can include fields that are uninitialized. The uninitialized “value” is represented by a question mark (?) .
  9. Multiclass

2 Type, Value, Class, Field, Definition, Name:

  1. Definition (Concrete Record) is declared by ‘def’.
  2. Class (Abstract Record) is declared by ‘class’.
  3. Fields are the primary data for records.
  4. Class can accept Template arguments to be parameterised.
  5. Some fields can be uninitialized and filled in later on.
  6. Every Value is required to have an associated type.
  7. Type :: = “bit” | “int” | “string” | “dag” | “bits” “<” TokInteger “>” | “list” “<” Type “>” | ClassID

3 TableGen Pattern Syntax:

  1. 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. }

  2. 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;
    

  3. 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;
    

  4. Instruction:

    class Instruction : InstructionEncoding;
    

  5. Misc:

    // Special TableGen-recognized dag nodes
    def set;
    def implicit;
    def node;
    def srcvalue;