Skip to content

'core' Dialect

Utility dialect to provide common features for other dialects. Dialect providing features that may be used by other dialects. These features can be used by including "vast/Dialect/Core/Utils.td" It also provides lazy.op for lazy evaluation of expressions and binary logical operations that make use of it.

Operations

core.bin.land (::vast::core::BinLAndOp)

VAST core dialect logical binary operation

Syntax:

operation ::= `core.bin.land` $lhs `,` $rhs attr-dict `:` functional-type(operands, results)

Core dialect logical binary operation. This operation takes two operands and returns one result, each of these is required to be of the same type.

The custom assembly form of the operation is as follows:

%result = %lhs, %rhs : type

Operands:

Operand Description
lhs any type
rhs any type

Results:

Result Description
result any type

core.bin.lor (::vast::core::BinLOrOp)

VAST core dialect logical binary operation

Syntax:

operation ::= `core.bin.lor` $lhs `,` $rhs attr-dict `:` functional-type(operands, results)

Core dialect logical binary operation. This operation takes two operands and returns one result, each of these is required to be of the same type.

The custom assembly form of the operation is as follows:

%result = %lhs, %rhs : type

Operands:

Operand Description
lhs any type
rhs any type

Results:

Result Description
result any type

core.implicit.return (::vast::core::ImplicitReturnOp)

VAST implicit return

Syntax:

operation ::= `core.implicit.return` $result `:` type($result) attr-dict

Op representing return that wasn't explicitely written in the source (e.g. in void fun(){}).

Traits: Core_ReturnLikeTrait, Core_SoftTerminatorTrait

Operands:

Operand Description
result variadic of any type

core.lazy.op (::vast::core::LazyOp)

Lazily evaluate a region.

Syntax:

operation ::= `core.lazy.op` $lazy attr-dict `:` type(results)

The operation serves to encapsulate delayed evaluation in its region.

Traits: NoTerminator

Results:

Result Description
result any type

core.module (::vast::core::ModuleOp)

VAST top level container operation

Syntax:

operation ::= `core.module` ($sym_name^)? attr-dict-with-keyword $body

A module represents a top-level container operation. We provide custom module operation to allow for custom symbol table management.

Traits: HasDefaultDLTIDataLayout, IsolatedFromAbove, NoRegionArguments, NoTerminator, ShadowingSymbolTable, SingleBlock

Interfaces: Core_SymbolTableOpInterface, Core_Symbol, DataLayoutOpInterface

Attributes:

AttributeMLIR TypeDescription
sym_name::mlir::StringAttrstring attribute

core.scope (::vast::core::ScopeOp)

VAST scope declaration

Syntax:

operation ::= `core.scope` $body attr-dict

Scope operation serves to represent explicitly high-level code scope. Other control flow operations represent scopes implicitly. It is a single-region operation.

Traits: Core_ScopeLikeTrait, NoTerminator, ShadowingSymbolTable

Interfaces: Core_SymbolTableOpInterface

core.select (::vast::core::SelectOp)

Select a value based on condition.

Syntax:

operation ::= `core.select` $cond `,` $thenRegion `,` $elseRegion attr-dict `:` functional-type(operands, results)

Usual select operation. First operand is selected if predicate is true, second otherwise (to mirror how ternary works in C).

%result = %cond %lhs, %rhs : type

Operands:

Operand Description
cond any type
thenRegion any type
elseRegion any type

Results:

Result Description
results variadic of any type

Attributes

BooleanAttr

An Attribute containing a boolean value

Syntax:

#core.bool<
  ::mlir::Type,   # type
  bool   # value
>

An boolean attribute is a literal attribute that represents a boolean value.

Parameters:

Parameter C++ type Description
type ::mlir::Type
value bool

FloatAttr

An Attribute containing a floating point value

Syntax:

#core.float<
  ::mlir::Type,   # type
  ::llvm::APFloat   # value
>

A float attribute is a literal attribute that represents a floating point value of the specified floating point type.

Parameters:

Parameter C++ type Description
type ::mlir::Type
value ::llvm::APFloat

GlobalLinkageKindAttr

Linkage type/kind

Syntax:

#core.global_linkage_kind<
  ::vast::core::GlobalLinkageKind   # value
>

Enum cases: * external (ExternalLinkage) * available_externally (AvailableExternallyLinkage) * linkonce (LinkOnceAnyLinkage) * linkonce_odr (LinkOnceODRLinkage) * weak (WeakAnyLinkage) * weak_odr (WeakODRLinkage) * internal (InternalLinkage) * private (PrivateLinkage) * extern_weak (ExternalWeakLinkage) * common (CommonLinkage) * appending (AppendingLinkage)

Parameters:

Parameter C++ type Description
value ::vast::core::GlobalLinkageKind an enum of type GlobalLinkageKind

IntegerAttr

An Attribute containing a integer value

Syntax:

#core.integer<
  ::mlir::Type,   # type
  ::llvm::APSInt   # value
>

An integer attribute is a literal attribute that represents an integral value of the specified integer type.

Parameters:

Parameter C++ type Description
type ::mlir::Type
value ::llvm::APSInt

SourceLanguageAttr

Module source language

Syntax:

#core.lang<
  ::vast::core::SourceLanguage   # value
>

Represents the source language used to generate the module.

Example:

// Module compiled from C.
module attributes {vast.core.lang = vast.core.lang<c>} {}
// Module compiled from C++.
module attributes {vast.core.lang = vast.core.lang<cxx>} {}

Parameters:

Parameter C++ type Description
value ::vast::core::SourceLanguage an enum of type SourceLanguage

VoidAttr

Attribute to represent void value.

Syntax:

#core.void<
  ::mlir::Type   # type
>

The VoidAttr is used to return void from statements uniformly.

Parameters:

Parameter C++ type Description
type ::mlir::Type

Types

FunctionType

Vast function type

Syntax:

!core.fn<
  ::llvm::ArrayRef<Type>,   # inputs
  ::llvm::ArrayRef<Type>,   # results
  bool   # varArg
>

The !core.fn is a function type. It consists of a variadic return type, and list of parameter types and can optionally be variadic.

Example:

!core.fn<() -> !hl.bool>
!core.fn<(!hl.char, !hl.char) -> !hl.int>
!core.fn<!i32 (!i32, ...)>

Parameters:

Parameter C++ type Description
inputs ::llvm::ArrayRef<Type>
results ::llvm::ArrayRef<Type>
varArg bool

Enums

DeclContextKind

declaration context kind

Cases:

Symbol Value String
dc_function 0 dc_function
dc_method 1 dc_method
dc_block 2 dc_block
dc_capture 3 dc_capture
dc_translation_unit 4 dc_translation_unit
dc_record 5 dc_record
dc_enum 6 dc_enum
dc_namespace 7 dc_namespace

GlobalLinkageKind

Linkage type/kind

Cases:

Symbol Value String
ExternalLinkage 0 external
AvailableExternallyLinkage 1 available_externally
LinkOnceAnyLinkage 2 linkonce
LinkOnceODRLinkage 3 linkonce_odr
WeakAnyLinkage 4 weak
WeakODRLinkage 5 weak_odr
InternalLinkage 7 internal
PrivateLinkage 8 private
ExternalWeakLinkage 9 extern_weak
CommonLinkage 10 common
AppendingLinkage 6 appending

SourceLanguage

Source language

Cases:

Symbol Value String
C 1 c
CXX 2 cxx

StorageClass

storage class

Cases:

Symbol Value String
sc_none 0 sc_none
sc_auto 1 sc_auto
sc_static 2 sc_static
sc_extern 3 sc_extern
sc_private_extern 4 sc_private_extern
sc_register 5 sc_register

StorageDuration

storage duration

Cases:

Symbol Value String
sd_none 0 sd_none
sd_automatic 1 sd_automatic
sd_thread 2 sd_thread
sd_static 3 sd_static
sd_dynamic 4 sd_dynamic

TSClass

thread storage class

Cases:

Symbol Value String
tsc_none 0 tsc_none
tsc_gnu_thread 1 tsc_gnu_thread
tsc_cxx_thread 2 tsc_cxx_thread
tsc_c_thread 3 tsc_c_thread