Skip to content

Commit

Permalink
Bump LLVM version to the latest
Browse files Browse the repository at this point in the history
  • Loading branch information
hanchenye committed Jul 19, 2023
1 parent 161cb0c commit 3e632c2
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion include/scalehls/Dialect/HLS/IR/HLSInterfaces.td
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def BufferLikeInterface : OpInterface<"BufferLikeInterface"> {
InterfaceMethod<"Return the depth of the buffer", "int32_t",
"getBufferDepth">,
InterfaceMethod<"Return the initial value of the buffer",
"llvm::Optional<mlir::TypedAttr>", "getBufferInitValue">,
"std::optional<mlir::TypedAttr>", "getBufferInitValue">,
];
}

Expand Down
10 changes: 5 additions & 5 deletions include/scalehls/Utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ bool crossRegionDominates(Operation *a, Operation *b);
/// Check if the lhsOp and rhsOp are in the same block. If so, return their
/// ancestors that are located at the same block. Note that in this check,
/// AffineIfOp is transparent.
Optional<std::pair<Operation *, Operation *>> checkSameLevel(Operation *lhsOp,
Operation *rhsOp);
std::optional<std::pair<Operation *, Operation *>>
checkSameLevel(Operation *lhsOp, Operation *rhsOp);

unsigned getCommonSurroundingLoops(Operation *A, Operation *B,
AffineLoopBand *band);

/// Calculate the upper and lower bound of the affine map if possible.
Optional<std::pair<int64_t, int64_t>> getBoundOfAffineMap(AffineMap map,
ValueRange operands);
std::optional<std::pair<int64_t, int64_t>>
getBoundOfAffineMap(AffineMap map, ValueRange operands);

/// Calculate partition factors through analyzing the "memrefType" and return
/// them in "factors". Meanwhile, the overall partition number is calculated and
Expand Down Expand Up @@ -128,7 +128,7 @@ void getLoopBands(Block &block, AffineLoopBands &bands,
void getArrays(Block &block, SmallVectorImpl<Value> &arrays,
bool allowArguments = true);

Optional<unsigned> getAverageTripCount(affine::AffineForOp forOp);
std::optional<unsigned> getAverageTripCount(affine::AffineForOp forOp);

bool checkDependence(Operation *A, Operation *B);

Expand Down
8 changes: 5 additions & 3 deletions lib/Dialect/HLS/IR/HLSUBUFOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ LogicalResult BufferOp::verify() {
}

int32_t BufferOp::getBufferDepth() { return getDepth(); }
Optional<TypedAttr> BufferOp::getBufferInitValue() { return getInitValue(); }
std::optional<TypedAttr> BufferOp::getBufferInitValue() {
return getInitValue();
}

void BufferOp::getEffects(
SmallVectorImpl<SideEffects::EffectInstance<MemoryEffects::Effect>>
Expand All @@ -169,8 +171,8 @@ void BufferOp::getEffects(
}

int32_t ConstBufferOp::getBufferDepth() { return 1; }
Optional<TypedAttr> ConstBufferOp::getBufferInitValue() {
return Optional<TypedAttr>();
std::optional<TypedAttr> ConstBufferOp::getBufferInitValue() {
return std::optional<TypedAttr>();
}

LogicalResult ConstBufferOp::verify() {
Expand Down
18 changes: 9 additions & 9 deletions lib/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ bool scalehls::crossRegionDominates(Operation *a, Operation *b) {
// Check if the lhsOp and rhsOp are in the same block. If so, return their
// ancestors that are located at the same block. Note that in this check,
// AffineIfOp is transparent.
Optional<std::pair<Operation *, Operation *>>
std::optional<std::pair<Operation *, Operation *>>
scalehls::checkSameLevel(Operation *lhsOp, Operation *rhsOp) {
// If lhsOp and rhsOp are already at the same level, return true.
if (lhsOp->getBlock() == rhsOp->getBlock())
Expand Down Expand Up @@ -438,7 +438,7 @@ scalehls::checkSameLevel(Operation *lhsOp, Operation *rhsOp) {
if (lhs->getBlock() == rhs->getBlock())
return std::pair<Operation *, Operation *>(lhs, rhs);

return Optional<std::pair<Operation *, Operation *>>();
return std::optional<std::pair<Operation *, Operation *>>();
}

/// Returns the number of surrounding loops common to 'loopsA' and 'loopsB',
Expand All @@ -462,7 +462,7 @@ unsigned scalehls::getCommonSurroundingLoops(Operation *A, Operation *B,
}

/// Calculate the lower and upper bound of the affine map if possible.
Optional<std::pair<int64_t, int64_t>>
std::optional<std::pair<int64_t, int64_t>>
scalehls::getBoundOfAffineMap(AffineMap map, ValueRange operands) {
if (map.isSingleConstant()) {
auto constBound = map.getSingleConstantResult();
Expand All @@ -471,7 +471,7 @@ scalehls::getBoundOfAffineMap(AffineMap map, ValueRange operands) {

// For now, we can only handle one result value map.
if (map.getNumResults() != 1)
return Optional<std::pair<int64_t, int64_t>>();
return std::optional<std::pair<int64_t, int64_t>>();

auto context = map.getContext();
SmallVector<int64_t, 4> lbs;
Expand All @@ -480,13 +480,13 @@ scalehls::getBoundOfAffineMap(AffineMap map, ValueRange operands) {
// Only if the affine map operands are induction variable, the calculation
// is possible.
if (!isAffineForInductionVar(operand))
return Optional<std::pair<int64_t, int64_t>>();
return std::optional<std::pair<int64_t, int64_t>>();

// Only if the owner for op of the induction variable has constant bound,
// the calculation is possible.
auto forOp = getForInductionVarOwner(operand);
if (!forOp.hasConstantBounds())
return Optional<std::pair<int64_t, int64_t>>();
return std::optional<std::pair<int64_t, int64_t>>();

auto lb = forOp.getConstantLowerBound();
auto ub = forOp.getConstantUpperBound();
Expand All @@ -512,7 +512,7 @@ scalehls::getBoundOfAffineMap(AffineMap map, ValueRange operands) {
if (auto constExpr = newExpr.dyn_cast<AffineConstantExpr>())
results.push_back(constExpr.getValue());
else
return Optional<std::pair<int64_t, int64_t>>();
return std::optional<std::pair<int64_t, int64_t>>();
}

auto minmax = std::minmax_element(results.begin(), results.end());
Expand Down Expand Up @@ -697,7 +697,7 @@ void scalehls::getArrays(Block &block, SmallVectorImpl<Value> &arrays,
}
}

Optional<unsigned> scalehls::getAverageTripCount(AffineForOp forOp) {
std::optional<unsigned> scalehls::getAverageTripCount(AffineForOp forOp) {
if (auto optionalTripCount = getConstantTripCount(forOp))
return optionalTripCount.value();
else {
Expand All @@ -716,7 +716,7 @@ Optional<unsigned> scalehls::getAverageTripCount(AffineForOp forOp) {
upperBound.value().first - lowerBound.value().second;
return (lowerTripCount + upperTripCount + 1) / 2;
} else
return Optional<unsigned>();
return std::optional<unsigned>();
}
}

Expand Down
2 changes: 1 addition & 1 deletion llvm-project
1 change: 0 additions & 1 deletion python/scalehls/dialects/HLSOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#ifndef PYTHON_SCALEHLS_DIALECTS_HLSOPS_TD
#define PYTHON_SCALEHLS_DIALECTS_HLSOPS_TD

include "mlir/Bindings/Python/Attributes.td"
include "scalehls/Dialect/HLS/IR/HLSOps.td"

#endif // PYTHON_SCALEHLS_DIALECTS_HLSOPS_TD
4 changes: 2 additions & 2 deletions tools/scalehls-opt/scalehls-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ int main(int argc, char **argv) {
mlir::scalehls::registerAllInterfaceExternalModels(registry);
mlir::scalehls::registerAllPasses();

return mlir::failed(mlir::MlirOptMain(
argc, argv, "ScaleHLS Optimization Tool", registry, true));
return mlir::failed(
mlir::MlirOptMain(argc, argv, "ScaleHLS Optimization Tool", registry));
}

0 comments on commit 3e632c2

Please sign in to comment.