scair.clair.macros

Members list

Type members

Classlikes

case class Anchor(directive: Directive)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class AssemblyFormatDirective(directives: Seq[Directive])

Declarative assembly format representation. Contains a sequence of directives that define the format.

Declarative assembly format representation. Contains a sequence of directives that define the format.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class AttrDictDirective() extends Directive

Directive for an operation's attribute dictionnary. Its presence is mandatory in every declarative assembly format, as this ensures the operation's unknown added attributes are carried by its syntax.

Directive for an operation's attribute dictionnary. Its presence is mandatory in every declarative assembly format, as this ensures the operation's unknown added attributes are carried by its syntax.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Directive
class Object
trait Matchable
class Any
Show all
case class AttributeDef(name: String, attributes: Seq[AttributeParamDef] = ...)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class AttributeParamDef(name: String, tpe: Type[_ <: AnyKind])

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait Directive

Base trait for assembly format directives. Directives represent a unit of the assembly format, and can generate printing and parsing implementations for their constructs.

Base trait for assembly format directives. Directives represent a unit of the assembly format, and can generate printing and parsing implementations for their constructs.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
case class LiteralDirective(literal: String) extends Directive

Directive for literal text in the assembly format. Examples include keywords, punctuation, and other fixed strings. Typically used to clarify semantic or solve ambiguity.

Directive for literal text in the assembly format. Examples include keywords, punctuation, and other fixed strings. Typically used to clarify semantic or solve ambiguity.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Directive
class Object
trait Matchable
class Any
Show all

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait MayVariadicOpInputDef extends OpInputDef

Attributes

Companion
object
Supertypes
trait OpInputDef
class Object
trait Matchable
class Any
Known subtypes
class OperandDef
class RegionDef
class ResultDef
class SuccessorDef
object OpInputDef

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
OpInputDef.type
sealed trait OpInputDef

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class OperandDef
class RegionDef
class ResultDef
class SuccessorDef
Show all
case class OpPropertyDef(name: String, tpe: Type[_ <: AnyKind], variadicity: Single.type | Optional.type = ..., constraint: Option[Expr[ConstraintImpl[_]]] = ..., defaultValue: Option[Expr[Any]]) extends OpInputDef, MayVariadicOpInputDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait OpInputDef
class Object
trait Matchable
class Any
Show all
case class OperandDef(name: String, tpe: Type[_ <: AnyKind], variadicity: Variadicity = ..., constraint: Option[Expr[ConstraintImpl[_]]] = ...) extends OpInputDef, MayVariadicOpInputDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait OpInputDef
class Object
trait Matchable
class Any
Show all
case class OperationDef(name: String, className: String, operands: Seq[OperandDef] = ..., results: Seq[ResultDef] = ..., regions: Seq[RegionDef] = ..., successors: Seq[SuccessorDef] = ..., properties: Seq[OpPropertyDef] = ..., assemblyFormat: Option[AssemblyFormatDirective] = ...)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class OptionalGroupDirective(anchor: Directive, directives: Seq[Directive]) extends Directive

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Directive
class Object
trait Matchable
class Any
Show all
case class PrintingState(var shouldEmitSpace: Boolean = ..., var lastWasPunctuation: Boolean = ...)

Holds state during printer generation to manage spacing and punctuation.

Holds state during printer generation to manage spacing and punctuation.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class RegionDef(name: String, variadicity: Variadicity = ...) extends OpInputDef, MayVariadicOpInputDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait OpInputDef
class Object
trait Matchable
class Any
Show all
case class ResultDef(name: String, tpe: Type[_ <: AnyKind], variadicity: Variadicity = ..., constraint: Option[Expr[ConstraintImpl[_]]] = ...) extends OpInputDef, MayVariadicOpInputDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait OpInputDef
class Object
trait Matchable
class Any
Show all
case class SuccessorDef(name: String, variadicity: Variadicity = ...) extends OpInputDef, MayVariadicOpInputDef

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait OpInputDef
class Object
trait Matchable
class Any
Show all
case class TypeDirective(construct: OperandDef | ResultDef) extends Directive

Directive for types of individual operands or results.

Directive for types of individual operands or results.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Directive
class Object
trait Matchable
class Any
Show all
case class VariableDirective(construct: OpInputDef) extends Directive

Directive for variables, handling operations' individual constructs (operands, results, regions, successors or properties).

Directive for variables, handling operations' individual constructs (operands, results, regions, successors or properties).

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Directive
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Types

Type helper to get the defined input type of a construct definition.

Type helper to get the defined input type of a construct definition.

Attributes

type DefinedInputOf[T <: OpInputDef, A <: Attribute] = T match { case OperandDef => Value[A] case ResultDef => Result[A] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => A }

Type helper to get the defined input type of a construct definition.

Type helper to get the defined input type of a construct definition.

Attributes

Value members

Concrete methods

def ADTFlatAttrInputMacro[Def <: AttributeDef](attrInputDefs: Seq[AttributeParamDef], adtAttrExpr: Expr[_])(using evidence$1: Type[Def], Quotes): Expr[Seq[Attribute]]
def ADTFlatInputMacro[Def <: OpInputDef](opInputDefs: Seq[Def], adtOpExpr: Expr[_])(using evidence$1: Type[Def], Quotes): Expr[Seq[DefinedInput[Def]]]

Get all constructs of the specified type flattened from the ADT expression.

Get all constructs of the specified type flattened from the ADT expression.

Type parameters

Def

The construct definition type.

Value parameters

adtOpExpr

The ADT expression.

opInputDefs

The construct definitions.

Attributes

def assemblyFormatP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[AssemblyFormatDirective]

Parser for the complete assembly format. Parses one or more directives into an AssemblyFormatDirective.

Parser for the complete assembly format. Parses one or more directives into an AssemblyFormatDirective.

Attributes

def assemblyIdP[$ : P]: ParsingRun[String]

Parses an assembly format identifier. Those should match Scala's identifier rules, for maximum compatibility with the ADT fields; this is an approximation.

Parses an assembly format identifier. Those should match Scala's identifier rules, for maximum compatibility with the ADT fields; this is an approximation.

Attributes

def attrDictDirectiveP[$ : P]: ParsingRun[AttrDictDirective]

Parser for attribute dictionary directives. Parses the keyword "attr-dict" into an AttrDictDirective.

Parser for attribute dictionary directives. Parses the keyword "attr-dict" into an AttrDictDirective.

Attributes

transparent inline def chainParsers(run: Expr[ParsingRun[Any]], next: Expr[ParsingRun[Any]])(using quotes: Quotes, ctx: Expr[ParsingRun[Any]]): Expr[ParsingRun[Any]]

Helper function to chain parsers together using fastparse's sequencing operator. Handles different return types by matching on the specific parser types.

Helper function to chain parsers together using fastparse's sequencing operator. Handles different return types by matching on the specific parser types.

Attributes

def constructExtractor[Def <: OpInputDef](d: Def)(using evidence$1: Type[Def], Quotes): Expr[((DefinedInput[Def] | Seq[DefinedInput[Def]]) => Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute }) | ((DefinedInput[Def] | Seq[DefinedInput[Def]]) => Seq[Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute }]) | ((DefinedInput[Def] | Seq[DefinedInput[Def]]) => Option[Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute }])]

Returns an extractor expression for the passed construct definition.

Returns an extractor expression for the passed construct definition.

Value parameters

defs

The constructs definitions.

Attributes

def constructPartitioner[Def <: OpInputDef](defs: Seq[Def])(using evidence$1: Type[Def], Quotes): Seq[Expr[((Map[String, Attribute], Seq[DefinedInput[Def]]) => DefinedInput[Def]) | ((Map[String, Attribute], Seq[DefinedInput[Def]]) => Seq[DefinedInput[Def]])]]

Partion constructs of a specified type. That is, check that they are in a coherent quantity, and partition them into the provided definitions.

Partion constructs of a specified type. That is, check that they are in a coherent quantity, and partition them into the provided definitions.

Type parameters

Def

The construct definition type.

Value parameters

defs

The construct definitions.

Attributes

Returns

A function of an operation and its flat sequence of constructs, returning the sequence of partitions according to the definitions.

def customPrintMacro(opDef: OperationDef, adtOpExpr: Expr[_], p: Expr[Printer])(using Quotes): Expr[Unit]
def defaultExprs[T](using evidence$1: Type[T], Quotes): Map[String, Expr[Any]]

For a case class T, returns a dictionary mapping field names to expressions representing the default value of that field, if defined.

For a case class T, returns a dictionary mapping field names to expressions representing the default value of that field, if defined.

Attributes

def deriveOperationCompanion[T <: Operation](using evidence$1: Type[T], Quotes): Expr[DerivedOperationCompanion[T]]
def derivedAttributeCompanion[T <: Attribute](using evidence$1: Type[T], Quotes): Expr[DerivedAttributeCompanion[T]]
def directiveP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[Directive]

Parser for any directive.

Parser for any directive.

Attributes

def expectSegmentSizes[Def <: OpInputDef](using evidence$1: Type[Def], Quotes): Expr[Map[String, Attribute] => Seq[Int]]

Expect a segmentSizes property of DenseArrayAttr type, and return it as a list of integers.

Expect a segmentSizes property of DenseArrayAttr type, and return it as a list of integers.

Type parameters

Def

The construct definition type.

Value parameters

op

The UnstructuredOp expression.

Attributes

def extractedConstructs[Def <: OpInputDef](defs: Seq[Def], flat: Expr[Seq[DefinedInput[Def]]], properties: Expr[Map[String, Attribute]])(using evidence$1: Type[Def], Quotes): Seq[Expr[Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute } | Seq[Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute }] | Option[Def match { case OperandDef => Value[_ <: Attribute] case ResultDef => Result[Attribute] case RegionDef => Region case SuccessorDef => Successor case OpPropertyDef => <: Attribute }]]]
def fromUnstructuredOperationMacro[T <: Operation](opDef: OperationDef, genExpr: Expr[DerivedOperationCompanion[T]#UnstructuredOp])(using evidence$1: Type[T], Quotes): Expr[T]

Attempt to create an ADT from an UnstructuredOp[ADT]

Attempt to create an ADT from an UnstructuredOp[ADT]

Type parameters

T

The ADT Type.

Value parameters

genExpr

The expression of the UnstructuredOp[ADT].

opDef

The OperationDef derived from the ADT.

Attributes

Returns

The ADT instance.

def generateCheckedPropertyArgument[A <: Attribute](list: Expr[Map[String, Attribute]], propName: String, defaultValue: Option[Expr[Any]])(using evidence$1: Type[A], Quotes): Expr[A]

Helper to check a property argument.

Helper to check a property argument.

Attributes

def generateOptionalCheckedPropertyArgument[A <: Attribute](list: Expr[Map[String, Attribute]], propName: String)(using evidence$1: Type[A], Quotes): Expr[Option[A]]
def getAttrConstructor[T](attrDef: AttributeDef, attributes: Expr[Seq[Attribute]])(using evidence$1: Type[T], Quotes): Expr[T]
def getAttrCustomParse[T <: Attribute](p: Expr[Parser], ctx: Expr[ParsingRun[Any]])(using evidence$1: Type[T], quotes: Quotes): Option[Expr[ParsingRun[T]]]
def getAttrDef[Label, Elem](using evidence$1: Type[Label], evidence$2: Type[Elem], Quotes): AttributeParamDef
def getAttrDefImpl[T](using evidence$1: Type[T], quotes: Quotes): AttributeDef
def getCompanion[T](using evidence$1: Type[T], quotes: Quotes): quotes.reflect.Symbol
def getConstructConstraint(_def: OpInputDef)(using Quotes): Type[_ <: AnyKind]

Helper to get the expected type of a construct definition's construct.

Helper to get the expected type of a construct definition's construct.

Attributes

def getConstructName[Def <: OpInputDef](using d: Type[Def], Quotes): String

Helper to get the name of a construct definition type.

Helper to get the name of a construct definition type.

Attributes

def getConstructSeq[Def <: OpInputDef](op: Expr[DerivedOperationCompanion[_]#UnstructuredOp])(using d: Type[Def], Quotes): Expr[Seq[DefinedInput[Def]]]

Helper to access the right sequence of constructs from an UnstructuredOp, given a construct definition type.

Helper to access the right sequence of constructs from an UnstructuredOp, given a construct definition type.

Attributes

def getConstructVariadicity(_def: OpInputDef)(using Quotes): Variadicity

Helper to get the variadicity of a construct definition's construct.

Helper to get the variadicity of a construct definition's construct.

Attributes

def getDefImpl[T <: Operation](using evidence$1: Type[T], quotes: Quotes): OperationDef
def getDefInput[Label, Elem](using defaults: Map[String, Expr[Any]])(using evidence$1: Type[Label], evidence$2: Type[Elem], Quotes): OpInputDef

Produces an OpInput to OperationDef given a definition of a Type.

Produces an OpInput to OperationDef given a definition of a Type.

Attributes

Returns

Input to OperationDef, either: OperandDef, ResultDef, RegionDef, SuccessorDef, OpPropertyDef

def getDefType(elem: Type[_ <: AnyKind])(using Quotes): Type[_ <: Attribute]
def getDefVariadicityAndType[Elem](using evidence$1: Type[Elem], Quotes): (Variadicity, Type[_ <: AnyKind])
def getOpCustomParse[T <: Operation](p: Expr[Parser], resNames: Expr[Seq[String]])(using evidence$1: Type[T], quotes: Quotes): Option[Expr[ParsingRun[Any] ?=> ParsingRun[T]]]
def getTypeConstraint(tpe: Type[_ <: AnyKind])(using Quotes): Option[Expr[ConstraintImpl[_ <: Constraint]]]
def literalDirectiveP[$ : P]: ParsingRun[LiteralDirective]

Parser for literal directives. Parses text enclosed in backticks as a literal directive.

Parser for literal directives. Parses text enclosed in backticks as a literal directive.

Attributes

def makeSegmentSizes[T <: MayVariadicOpInputDef](hasMultiVariadic: Boolean, defs: Seq[T], adtOpExpr: Expr[_])(using evidence$1: Type[T], Quotes): Option[Expr[(String, Attribute)]]
def multivariadicConstructPartitioner[Def <: OpInputDef](defs: Seq[Def])(using evidence$1: Type[Def], Quotes): Seq[Expr[((Map[String, Attribute], Seq[DefinedInput[Def]]) => DefinedInput[Def]) | ((Map[String, Attribute], Seq[DefinedInput[Def]]) => Seq[DefinedInput[Def]])]]

Partition a construct sequence, in the case of multiple variadic definitions

Partition a construct sequence, in the case of multiple variadic definitions

Attributes

See also
def operandsMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[Seq[Value[Attribute]]]
def optionalConstructExtractor[Def <: OpInputDef, t <: Attribute](d: Def)(using evidence$1: Type[Def], evidence$2: Type[t], Quotes): Expr[(DefinedInput[Def] | Seq[DefinedInput[Def]]) => Option[DefinedInputOf[Def, t]]]
def optionalGroupDirectiveP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[Directive]
def parametersMacro(attrDef: AttributeDef, adtAttrExpr: Expr[_])(using Quotes): Expr[Seq[Attribute]]

Parse a declarative assembly format string into an AssemblyFormatDirective, its internal representation for implementation generation.

Parse a declarative assembly format string into an AssemblyFormatDirective, its internal representation for implementation generation.

Attributes

def parseMacro[O <: Operation](opDef: OperationDef, p: Expr[Parser], resNames: Expr[Seq[String]])(using evidence$1: Type[O], Quotes): Expr[ParsingRun[Any] ?=> ParsingRun[O]]
def possiblyAnchoredDirectiveP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[Anchor | Directive]
def propertiesMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[Map[String, Attribute]]
def regionsMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[Seq[Region]]
def resultsMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[Seq[Result[Attribute]]]
def selectMember[T](obj: Expr[_], name: String)(using evidence$1: Type[T], Quotes): Expr[T]

Small helper to select a member of an expression.

Small helper to select a member of an expression.

Value parameters

name

The name of the member to select.

obj

The object to select the member from.

Attributes

def singleConstructExtractor[Def <: OpInputDef, t <: Attribute](d: Def)(using evidence$1: Type[Def], evidence$2: Type[t], Quotes): Expr[(DefinedInput[Def] | Seq[DefinedInput[Def]]) => DefinedInputOf[Def, t]]
def stringifyLabels[Elems](using evidence$1: Type[Elems], Quotes): List[String]

Translates a Tuple of string types into a list of strings.

Translates a Tuple of string types into a list of strings.

Attributes

Returns

Tuple of String types

def successorsMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[Seq[Successor]]
def summonAttrDefs[Labels, Elems](using evidence$1: Type[Labels], evidence$2: Type[Elems], Quotes): List[AttributeParamDef]
def summonInput[Labels, Elems](using defaults: Map[String, Expr[Any]])(using evidence$1: Type[Labels], evidence$2: Type[Elems], Quotes): List[OpInputDef]

Loops through a Tuple of Input definitions and produces a List of inputs to OperationDef.

Loops through a Tuple of Input definitions and produces a List of inputs to OperationDef.

Attributes

Returns

Lambda that produces an input to OperationDef, given a string

def tryConstruct[T](opDef: OperationDef, operands: Expr[Seq[Value[Attribute]]], results: Expr[Seq[Result[Attribute]]], regions: Expr[Seq[Region]], successors: Expr[Seq[Successor]], properties: Expr[Map[String, Attribute]])(using evidence$1: Type[T], Quotes): Expr[T]

Return all named arguments for the primary constructor of an ADT. Those are checked, in the sense that they are checked to be of the correct types and numbers.

Return all named arguments for the primary constructor of an ADT. Those are checked, in the sense that they are checked to be of the correct types and numbers.

Value parameters

op

The UnstructuredOp instance.

opDef

The OperationDef derived from the ADT.

Attributes

Returns

The checked named arguments for the primary constructor of the ADT.

def typeDirectiveP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[TypeDirective]

Parser for type directives. Parses "type($var)" where $var is a variable directive.

Parser for type directives. Parses "type($var)" where $var is a variable directive.

Attributes

def uniadicConstructPartitioner[Def <: OpInputDef](defs: Seq[Def])(using evidence$1: Type[Def], Quotes): Seq[Expr[(Map[String, Attribute], Seq[DefinedInput[Def]]) => DefinedInput[Def]]]

Partition a construct sequence, in the case of no variadic defintion.

Partition a construct sequence, in the case of no variadic defintion.

Attributes

See also
def univariadicConstructPartitioner[Def <: OpInputDef](defs: Seq[Def])(using evidence$1: Type[Def], Quotes): Seq[Expr[((Map[String, Attribute], Seq[DefinedInput[Def]]) => DefinedInput[Def]) | ((Map[String, Attribute], Seq[DefinedInput[Def]]) => Seq[DefinedInput[Def]])]]

Partition a construct sequence, in the case of a single variadic defintion.

Partition a construct sequence, in the case of a single variadic defintion.

Attributes

See also
def variableDirectiveP[$](using evidence$1: ParsingRun[$], opDef: OperationDef): ParsingRun[VariableDirective]

Parser for variable directives. Parses a dollar sign followed by an identifier, which references a construct of the Operation.

Parser for variable directives. Parses a dollar sign followed by an identifier, which references a construct of the Operation.

Attributes

def variadicConstructExtractor[Def <: OpInputDef, t <: Attribute](d: Def)(using evidence$1: Type[Def], evidence$2: Type[t], Quotes): Expr[(DefinedInput[Def] | Seq[DefinedInput[Def]]) => Seq[DefinedInputOf[Def, t]]]
def verifyMacro(opDef: OperationDef, adtOpExpr: Expr[_])(using Quotes): Expr[OK[Operation]]