serene/include/serene/sir/dialect.td

60 lines
1.5 KiB
TableGen
Raw Normal View History

#ifndef SERENE_DIALECT
#define SERENE_DIALECT
include "mlir/IR/OpBase.td"
2021-03-26 21:39:25 +00:00
include "mlir/Interfaces/SideEffectInterfaces.td"
2021-03-26 21:39:25 +00:00
// Dialect definition. It will directly generate the SereneDialect class
def Serene_Dialect : Dialect {
let name = "serene";
let cppNamespace = "::serene::sir";
}
2021-03-26 21:39:25 +00:00
// Base class for Serene dialect operations. This operation inherits from the base
// `Op` class in OpBase.td, and provides:
// * The parent dialect of the operation.
// * The mnemonic for the operation, or the name without the dialect prefix.
// * A list of traits for the operation.
class Serene_Op<string mnemonic, list<OpTrait> traits = []> :
Op<Serene_Dialect, mnemonic, traits>;
// All of the types will extend this class.
class Serene_Type<string name> : TypeDef<Serene_Dialect, name> { }
def SymbolType : Serene_Type<"Symbol"> {
let mnemonic = "symbol";
let summary = "A typical Lisp symbol";
let description = [{
A symbol is just a name and nothing more. Just a name
to give to a value or to use it as it is.
}];
// let cppNamespace = "::serene::sir";
let parameters = (ins "std::string":$name);
// We define the printer inline.
let printer = [{
$_printer << "Symbol<" << getImpl()->name << ">";
}];
// The parser is defined here also.
let parser = [{
if ($_parser.parseLess())
return Type();
std::string name;
if ($_parser.parseInteger(name))
return Type();
return get($_ctxt, name);
}];
}
#endif // SERENE_DIALECT