Skip to content

Commit

Permalink
Upgraded MLIR/LLVM.
Browse files Browse the repository at this point in the history
- The submodule of the LLVM monorepo points to the latest commit of that repo now.
- Some changes in the prototype code were required to adapt to the new version of MLIR/LLVM.
  • Loading branch information
pdamme committed Mar 22, 2021
1 parent 130c7ad commit 5605c02
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
4 changes: 1 addition & 3 deletions src/api/cli/daphnec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include "parser/daphnedsl/MLIRGenVisitors.h"
#include "ir/daphneir/Daphne.h"
#include "ir/daphneir/Passes.h"
#define GET_TYPEDEF_CLASSES
#include <ir/daphneir/DaphneOpsTypes.cpp.inc>

#include "antlr4-runtime.h"
#include "llvm/Support/TargetSelect.h"
Expand All @@ -18,7 +16,7 @@
#include "mlir/Pass/PassManager.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Target/LLVMIR.h"
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"

#include <iostream>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/lowering/LowerToLLVMPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void DaphneLowerToLLVMPass::runOnOperation()
{
auto module = getOperation();

OwningRewritePatternList patterns;
OwningRewritePatternList patterns(&getContext());

LLVMTypeConverter typeConverter(&getContext());
typeConverter.addConversion([&](daphne::MatrixType matType)
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/lowering/RewriteToCallKernelOpPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void RewriteToCallKernelOpPass::runOnOperation()
{
auto module = getOperation();

OwningRewritePatternList patterns;
OwningRewritePatternList patterns(&getContext());

// convert other operations
ConversionTarget target(getContext());
Expand Down
8 changes: 5 additions & 3 deletions src/ir/daphneir/DaphneDialect.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <ir/daphneir/Daphne.h>
#define GET_OP_CLASSES
#include <ir/daphneir/DaphneOps.cpp.inc>
#define GET_TYPEDEF_CLASSES
#include <ir/daphneir/DaphneOpsTypes.cpp.inc>

#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
Expand Down Expand Up @@ -64,15 +66,15 @@ mlir::OpFoldResult mlir::daphne::ConstantOp::fold(mlir::ArrayRef<mlir::Attribute
return value();
}

::mlir::LogicalResult mlir::daphne::MatrixType::verifyConstructionInvariants(::mlir::Location loc, Type elementType)
::mlir::LogicalResult mlir::daphne::MatrixType::verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, Type elementType)
{
if (elementType.isSignedInteger(64) || elementType.isF64())
return mlir::success();
else
return mlir::emitError(loc) << "invalid matrix element type: " << elementType;
return emitError() << "invalid matrix element type: " << elementType;
}

::mlir::LogicalResult mlir::daphne::FrameType::verifyConstructionInvariants(::mlir::Location loc, std::vector<Type> columnTypes)
::mlir::LogicalResult mlir::daphne::FrameType::verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, std::vector<Type> columnTypes)
{
return mlir::success();
}
20 changes: 10 additions & 10 deletions src/ir/daphneir/DaphneOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def Daphne_TransposeOp : Daphne_Op<"t"> {
let results = (outs Matrix:$res);

let builders = [
OpBuilderDAG<(ins "Value":$input), [{
OpBuilder<(ins "Value":$input), [{
auto ty = input.getType().cast<MatrixType>();
build($_builder, $_state, ty, input);
}]>,
Expand Down Expand Up @@ -554,19 +554,19 @@ def Daphne_ConstantOp : Daphne_Op<"constant", [ConstantLike, NoSideEffect]> {
let results = (outs AnyTypeOf<[AnyScalar, Matrix]>:$result);

let builders = [
OpBuilderDAG<(ins "Attribute":$value), [{
OpBuilder<(ins "Attribute":$value), [{
build($_builder, $_state, value.getType(), value);
}]>,
OpBuilderDAG<(ins "double":$value), [{
OpBuilder<(ins "double":$value), [{
build($_builder, $_state, $_builder.getF64FloatAttr(value));
}]>,
//OpBuilderDAG<(ins "float":$value), [{
//OpBuilder<(ins "float":$value), [{
// build($_builder, $_state, $_builder.getF32FloatAttr(value));
//}]>,
OpBuilderDAG<(ins "int64_t":$value), [{
OpBuilder<(ins "int64_t":$value), [{
build($_builder, $_state, $_builder.getIntegerAttr($_builder.getIntegerType(64, true), value));
}]>,
//OpBuilderDAG<(ins "int":$value), [{
//OpBuilder<(ins "int":$value), [{
// build($_builder, $_state, $_builder.getI32IntegerAttr(value));
//}]>,
];
Expand All @@ -584,7 +584,7 @@ def Daphne_ReturnOp : Daphne_Op<"return", [NoSideEffect, Terminator, ReturnLike,
}];

let builders = [
OpBuilderDAG<(ins), [{
OpBuilder<(ins), [{
build($_builder, $_state, llvm::None);
}]>
];
Expand All @@ -597,12 +597,12 @@ def Daphne_CallKernelOp : Daphne_Op<"call_kernel"> {
let results = (outs Variadic<AnyType>);

let builders = [
OpBuilderDAG<(ins "StringAttr":$callee, CArg<"ValueRange", "{}">:$operands, CArg<"TypeRange", "{}">:$results), [{
OpBuilder<(ins "StringAttr":$callee, CArg<"ValueRange", "{}">:$operands, CArg<"TypeRange", "{}">:$results), [{
$_state.addOperands(operands);
$_state.addAttribute("callee", callee);
$_state.addTypes(results);
}]>,
OpBuilderDAG<(ins "StringRef":$callee, CArg<"ValueRange", "{}">:$operands, CArg<"TypeRange", "{}">:$results), [{
OpBuilder<(ins "StringRef":$callee, CArg<"ValueRange", "{}">:$operands, CArg<"TypeRange", "{}">:$results), [{
build($_builder, $_state, $_builder.getStringAttr(callee), operands, results);
}]>,
];
Expand Down Expand Up @@ -636,7 +636,7 @@ class Daphne_ElementwiseBinaryOp<string mnemonic, list<OpTrait> traits = []> :
let results = (outs AnyTypeOf<[AnyScalar, Matrix]>:$result);

let builders = [
OpBuilderDAG<(ins "Value":$lhs, "Value":$rhs), [{
OpBuilder<(ins "Value":$lhs, "Value":$rhs), [{
$_state.addTypes(lhs.getType());
$_state.addOperands({lhs, rhs});
}]>
Expand Down
4 changes: 2 additions & 2 deletions src/ir/daphneir/DaphneTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def Matrix : Daphne_Type<"Matrix"> {
let summary = "matrix";

let parameters = (ins "::mlir::Type":$elementType);
let genVerifyInvariantsDecl = 1;
let genVerifyDecl = 1;
}

// TODO We could omit the "Of" and have it default to ScalarType.
Expand All @@ -35,7 +35,7 @@ def Frame : Daphne_Type<"Frame"> {
let summary = "frame";

let parameters = (ins "std::vector<::mlir::Type>":$columnTypes);
let genVerifyInvariantsDecl = 1;
let genVerifyDecl = 1;
}

def MatrixOrFrame : AnyTypeOf<[Matrix, Frame]>;
Expand Down
2 changes: 1 addition & 1 deletion src/parser/daphnedsl/MLIRGenVisitors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Location DaphneMlirVisitor::getLocMLIR(antlr4::Token *token)
auto filename = token->getTokenSource()->getSourceName();
auto line = token->getLine();
auto col = token->getCharPositionInLine();
return builder.getFileLineColLoc(builder.getIdentifier(filename), line, col);
return mlir::FileLineColLoc::get(builder.getIdentifier(filename), line, col);
}

antlrcpp::Any DaphneMlirVisitor::visitFloatType(DaphneParser::FloatTypeContext *ctx)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/llvm-project
Submodule llvm-project updated 7974 files

0 comments on commit 5605c02

Please sign in to comment.