#include "mlir-c/Dialect/PDL.h"
#include "mlir-c/BuiltinTypes.h"
#include "mlir-c/IR.h"
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
void testAttributeType(MlirContext ctx) {
fprintf(stderr, "testAttributeType\n");
MlirType parsedType = mlirTypeParseGet(
ctx, mlirStringRefCreateFromCString("!pdl.attribute"));
MlirType constructedType = mlirPDLAttributeTypeGet(ctx);
assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType");
assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType");
fprintf(stderr, "parsedType isa PDLType: %d\n",
mlirTypeIsAPDLType(parsedType));
fprintf(stderr, "parsedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(parsedType));
fprintf(stderr, "parsedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(parsedType));
fprintf(stderr, "parsedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(parsedType));
fprintf(stderr, "parsedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(parsedType));
fprintf(stderr, "parsedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(parsedType));
fprintf(stderr, "constructedType isa PDLType: %d\n",
mlirTypeIsAPDLType(constructedType));
fprintf(stderr, "constructedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(constructedType));
fprintf(stderr, "constructedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(constructedType));
fprintf(stderr, "constructedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(constructedType));
fprintf(stderr, "constructedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(constructedType));
fprintf(stderr, "constructedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType));
mlirTypeDump(parsedType);
mlirTypeDump(constructedType);
fprintf(stderr, "\n\n");
}
void testOperationType(MlirContext ctx) {
fprintf(stderr, "testOperationType\n");
MlirType parsedType = mlirTypeParseGet(
ctx, mlirStringRefCreateFromCString("!pdl.operation"));
MlirType constructedType = mlirPDLOperationTypeGet(ctx);
assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType");
assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType");
fprintf(stderr, "parsedType isa PDLType: %d\n",
mlirTypeIsAPDLType(parsedType));
fprintf(stderr, "parsedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(parsedType));
fprintf(stderr, "parsedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(parsedType));
fprintf(stderr, "parsedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(parsedType));
fprintf(stderr, "parsedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(parsedType));
fprintf(stderr, "parsedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(parsedType));
fprintf(stderr, "constructedType isa PDLType: %d\n",
mlirTypeIsAPDLType(constructedType));
fprintf(stderr, "constructedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(constructedType));
fprintf(stderr, "constructedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(constructedType));
fprintf(stderr, "constructedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(constructedType));
fprintf(stderr, "constructedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(constructedType));
fprintf(stderr, "constructedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType));
mlirTypeDump(parsedType);
mlirTypeDump(constructedType);
fprintf(stderr, "\n\n");
}
void testRangeType(MlirContext ctx) {
fprintf(stderr, "testRangeType\n");
MlirType typeType = mlirPDLTypeTypeGet(ctx);
MlirType parsedType = mlirTypeParseGet(
ctx, mlirStringRefCreateFromCString("!pdl.range<type>"));
MlirType constructedType = mlirPDLRangeTypeGet(typeType);
MlirType elementType = mlirPDLRangeTypeGetElementType(constructedType);
assert(!mlirTypeIsNull(typeType) && "couldn't get PDLTypeType");
assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType");
assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType");
fprintf(stderr, "parsedType isa PDLType: %d\n",
mlirTypeIsAPDLType(parsedType));
fprintf(stderr, "parsedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(parsedType));
fprintf(stderr, "parsedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(parsedType));
fprintf(stderr, "parsedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(parsedType));
fprintf(stderr, "parsedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(parsedType));
fprintf(stderr, "parsedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(parsedType));
fprintf(stderr, "constructedType isa PDLType: %d\n",
mlirTypeIsAPDLType(constructedType));
fprintf(stderr, "constructedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(constructedType));
fprintf(stderr, "constructedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(constructedType));
fprintf(stderr, "constructedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(constructedType));
fprintf(stderr, "constructedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(constructedType));
fprintf(stderr, "constructedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(typeType, elementType));
mlirTypeDump(parsedType);
mlirTypeDump(constructedType);
mlirTypeDump(elementType);
fprintf(stderr, "\n\n");
}
void testTypeType(MlirContext ctx) {
fprintf(stderr, "testTypeType\n");
MlirType parsedType = mlirTypeParseGet(
ctx, mlirStringRefCreateFromCString("!pdl.type"));
MlirType constructedType = mlirPDLTypeTypeGet(ctx);
assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType");
assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType");
fprintf(stderr, "parsedType isa PDLType: %d\n",
mlirTypeIsAPDLType(parsedType));
fprintf(stderr, "parsedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(parsedType));
fprintf(stderr, "parsedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(parsedType));
fprintf(stderr, "parsedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(parsedType));
fprintf(stderr, "parsedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(parsedType));
fprintf(stderr, "parsedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(parsedType));
fprintf(stderr, "constructedType isa PDLType: %d\n",
mlirTypeIsAPDLType(constructedType));
fprintf(stderr, "constructedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(constructedType));
fprintf(stderr, "constructedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(constructedType));
fprintf(stderr, "constructedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(constructedType));
fprintf(stderr, "constructedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(constructedType));
fprintf(stderr, "constructedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType));
mlirTypeDump(parsedType);
mlirTypeDump(constructedType);
fprintf(stderr, "\n\n");
}
void testValueType(MlirContext ctx) {
fprintf(stderr, "testValueType\n");
MlirType parsedType = mlirTypeParseGet(
ctx, mlirStringRefCreateFromCString("!pdl.value"));
MlirType constructedType = mlirPDLValueTypeGet(ctx);
assert(!mlirTypeIsNull(parsedType) && "couldn't parse PDLAttributeType");
assert(!mlirTypeIsNull(constructedType) && "couldn't construct PDLAttributeType");
fprintf(stderr, "parsedType isa PDLType: %d\n",
mlirTypeIsAPDLType(parsedType));
fprintf(stderr, "parsedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(parsedType));
fprintf(stderr, "parsedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(parsedType));
fprintf(stderr, "parsedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(parsedType));
fprintf(stderr, "parsedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(parsedType));
fprintf(stderr, "parsedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(parsedType));
fprintf(stderr, "constructedType isa PDLType: %d\n",
mlirTypeIsAPDLType(constructedType));
fprintf(stderr, "constructedType isa PDLAttributeType: %d\n",
mlirTypeIsAPDLAttributeType(constructedType));
fprintf(stderr, "constructedType isa PDLOperationType: %d\n",
mlirTypeIsAPDLOperationType(constructedType));
fprintf(stderr, "constructedType isa PDLRangeType: %d\n",
mlirTypeIsAPDLRangeType(constructedType));
fprintf(stderr, "constructedType isa PDLTypeType: %d\n",
mlirTypeIsAPDLTypeType(constructedType));
fprintf(stderr, "constructedType isa PDLValueType: %d\n",
mlirTypeIsAPDLValueType(constructedType));
fprintf(stderr, "equal: %d\n", mlirTypeEqual(parsedType, constructedType));
mlirTypeDump(parsedType);
mlirTypeDump(constructedType);
fprintf(stderr, "\n\n");
}
int main(void) {
MlirContext ctx = mlirContextCreate();
mlirDialectHandleRegisterDialect(mlirGetDialectHandle__pdl__(), ctx);
testAttributeType(ctx);
testOperationType(ctx);
testRangeType(ctx);
testTypeType(ctx);
testValueType(ctx);
mlirContextDestroy(ctx);
return EXIT_SUCCESS;
}