MLIR

Multi-Level IR Compiler Framework

'emitc' Dialect

Attribute definition 

OpaqueAttr 

An opaque attribute

An opaque attribute of which the value gets emitted as is.

Example:

#emitc.opaque<"">
#emitc.opaque<"NULL">
#emitc.opaque<"nullptr">

Parameters: 

ParameterC++ typeDescription
value::llvm::StringRefthe opaque value

Type constraint definition 

An opaque type 

An opaque data type of which the value gets emitted as is.

Example:

!emitc.opaque<"int">
!emitc.opaque<"float *">
!emitc.opaque<"std::vector<std::string>">

Operation definition 

emitc.apply (::mlir::emitc::ApplyOp) 

Apply operation

Syntax:

operation ::= `emitc.apply` $applicableOperator `(` $operand `)` attr-dict `:` functional-type($operand, results)

With the apply operation the operators & (address of) and * (contents of) can be applied to a single operand.

Example:

// Custom form of applying the & operator.
%0 = emitc.apply "&"(%arg0) : (i32) -> !emitc.opaque<"int32_t*">

// Generic form of the same operation.
%0 = "emitc.apply"(%arg0) {applicableOperator = "&"}
    : (i32) -> !emitc.opaque<"int32_t*">

Attributes: 

AttributeMLIR TypeDescription
applicableOperator::mlir::StringAttrstring attribute

Operands: 

OperandDescription
operandany type

Results: 

ResultDescription
resultany type

emitc.call (::mlir::emitc::CallOp) 

Call operation

Syntax:

operation ::= `emitc.call` $callee `(` $operands `)` attr-dict `:` functional-type($operands, results)

The call operation represents a C++ function call. The call allows specifying order of operands and attributes in the call as follows:

  • integer value of index type refers to an operand;
  • attribute which will get lowered to constant value in call;

Example:

// Custom form defining a call to `foo()`.
%0 = emitc.call "foo" () : () -> i32

// Generic form of the same operation.
%0 = "emitc.call"() {callee = "foo"} : () -> i32

Attributes: 

AttributeMLIR TypeDescription
callee::mlir::StringAttrstring attribute
args::mlir::ArrayAttrarray attribute
template_args::mlir::ArrayAttrarray attribute

Operands: 

OperandDescription
operandsany type

Results: 

ResultDescription
«unnamed»any type

emitc.constant (::mlir::emitc::ConstantOp) 

Constant operation

The constant operation produces an SSA value equal to some constant specified by an attribute. This can be used to form simple integer and floating point constants, as well as more exotic things like tensor constants. The constant operation also supports the EmitC opaque attribute and the EmitC opaque type.

Example:

// Integer constant
%0 = "emitc.constant"(){value = 42 : i32} : () -> i32

// Constant emitted as `int32_t* = NULL;`
%1 = "emitc.constant"()
    {value = #emitc.opaque<"NULL"> : !emitc.opaque<"int32_t*">}
    : () -> !emitc.opaque<"int32_t*">

Attributes: 

AttributeMLIR TypeDescription
value::mlir::Attributeany attribute

Results: 

ResultDescription
«unnamed»any type

emitc.include (::mlir::emitc::IncludeOp) 

Include operation

The include operation allows to define a source file inclusion via the #include directive.

Example:

// Custom form defining the inclusion of `<myheader>`.
emitc.include <"myheader.h">

// Generic form of the same operation.
"emitc.include" (){include = "myheader.h", is_standard_include} : () -> ()

// Custom form defining the inclusion of `"myheader"`.
emitc.include "myheader.h"

// Generic form of the same operation.
"emitc.include" (){include = "myheader.h"} : () -> ()

Attributes: 

AttributeMLIR TypeDescription
include::mlir::StringAttrstring attribute
is_standard_include::mlir::UnitAttrunit attribute

Type definition 

OpaqueType 

An opaque type

An opaque data type of which the value gets emitted as is.

Example:

!emitc.opaque<"int">
!emitc.opaque<"float *">
!emitc.opaque<"std::vector<std::string>">

Parameters: 

ParameterC++ typeDescription
value::llvm::StringRefthe opaque value