Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
j2kun committed Apr 3, 2024
1 parent ec64164 commit 9c65ada
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 20 deletions.
8 changes: 5 additions & 3 deletions lib/polygeist/Ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4984,7 +4984,7 @@ template <typename T> struct BufferElimination : public OpRewritePattern<T> {
if (!opd)
continue;
auto val = dyn_cast<BlockArgument>(
((Value)load.getMapOperands()[opd.getPosition()]));
((Value)load.getMapOperands()[opd.getPosition()]));
if (!val)
continue;

Expand Down Expand Up @@ -5034,7 +5034,7 @@ template <typename T> struct BufferElimination : public OpRewritePattern<T> {
if (!opd)
continue;
auto val = dyn_cast<BlockArgument>(
((Value)load.getMapOperands()[opd.getPosition()]));
((Value)load.getMapOperands()[opd.getPosition()]));
if (!val)
continue;

Expand Down Expand Up @@ -5302,7 +5302,9 @@ struct AffineBufferElimination : public OpRewritePattern<T> {
auto i = idxp.index();
if (!idx.isValue) {
if (auto ald = dyn_cast<affine::AffineLoadOp>(ld)) {
if (auto ac = ald.getAffineMap().getResult(i).dyn_cast<AffineConstantExpr>()) {
if (auto ac = ald.getAffineMap()
.getResult(i)
.dyn_cast<AffineConstantExpr>()) {
if (idx == ac.getValue())
continue;
}
Expand Down
12 changes: 4 additions & 8 deletions lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,7 @@ struct CAllocaOpLowering : public AllocLikeOpLowering<memref::AllocaOp> {
ConversionPatternRewriter &rewriter) const override {
Location loc = allocaOp.getLoc();
MemRefType originalType = allocaOp.getType();
auto convertedType =
dyn_cast_or_null<LLVM::LLVMPointerType>(
auto convertedType = dyn_cast_or_null<LLVM::LLVMPointerType>(
getTypeConverter()->convertType(originalType));
auto elTy = convertMemrefElementTypeForLLVMPointer(
originalType, *this->getTypeConverter());
Expand Down Expand Up @@ -1015,8 +1014,7 @@ struct CAllocOpLowering : public AllocLikeOpLowering<memref::AllocOp> {
auto module = allocOp->getParentOfType<ModuleOp>();
Location loc = allocOp.getLoc();
MemRefType originalType = allocOp.getType();
auto convertedType =
dyn_cast_or_null<LLVM::LLVMPointerType>(
auto convertedType = dyn_cast_or_null<LLVM::LLVMPointerType>(
getTypeConverter()->convertType(originalType));

if (!convertedType)
Expand Down Expand Up @@ -1197,10 +1195,8 @@ struct CLoadStoreOpLowering : public ConvertOpToLLVMPattern<OpTy> {
ConversionPatternRewriter &rewriter) const {
Location loc = op.getLoc();
MemRefType originalType = op.getMemRefType();
auto convertedType =
dyn_cast_or_null<LLVM::LLVMPointerType>(
this->getTypeConverter()
->convertType(originalType));
auto convertedType = dyn_cast_or_null<LLVM::LLVMPointerType>(
this->getTypeConverter()->convertType(originalType));
if (!convertedType) {
(void)rewriter.notifyMatchFailure(loc, "unsupported memref type");
return nullptr;
Expand Down
7 changes: 3 additions & 4 deletions lib/polygeist/Passes/ConvertToOpaquePtr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,9 @@ struct GEPConversion : public OpConversionPattern<LLVM::GEPOp> {
Operation *rewritten;
TypeAttr elty = nullptr;
if (!op->getAttr(kElemTypeAttrName))
elty = TypeAttr::get(
getTypeConverter()->convertType(
dyn_cast<LLVM::LLVMPointerType>(
op.getOperand(0).getType()).getElementType()));
elty = TypeAttr::get(getTypeConverter()->convertType(
dyn_cast<LLVM::LLVMPointerType>(op.getOperand(0).getType())
.getElementType()));
if (convertPtrsToOpaque(op, rewritten, elty, adaptor.getOperands(),
rewriter, getTypeConverter())
.failed())
Expand Down
5 changes: 2 additions & 3 deletions tools/cgeist/Lib/ValueCategory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ void ValueCategory::store(mlir::Location loc, mlir::OpBuilder &builder,
if (auto mt = dyn_cast<MemRefType>(val.getType())) {
assert(mt.getShape().size() == 1 && "must have size 1");
if (auto PT = dyn_cast<mlir::LLVM::LLVMPointerType>(toStore.getType())) {
if (auto MT = dyn_cast<mlir::MemRefType>(val.getType()
.cast<MemRefType>()
.getElementType())) {
if (auto MT = dyn_cast<mlir::MemRefType>(
val.getType().cast<MemRefType>().getElementType())) {
assert(MT.getShape().size() == 1);
assert(MT.getShape()[0] == ShapedType::kDynamic);
assert(MT.getElementType() == PT.getElementType());
Expand Down
4 changes: 2 additions & 2 deletions tools/polymer/lib/Transforms/Reg2Mem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ static void demoteRegisterToMemory(mlir::func::FuncOp f, OpBuilder &b) {
mlir::Value val = defUsesPair.first;

// Create the alloca op for the scratchpad.
memref::AllocaOp allocaOp = createScratchpadAllocaOp(
dyn_cast<mlir::OpResult>(val), b, &entryBlock);
memref::AllocaOp allocaOp =
createScratchpadAllocaOp(dyn_cast<mlir::OpResult>(val), b, &entryBlock);

// Create the store op that stores val into the scratchpad for future uses.
createScratchpadStoreOp(val, allocaOp, b);
Expand Down

0 comments on commit 9c65ada

Please sign in to comment.