Skip to content

Commit 475409c

Browse files
committed
Reformat code
1 parent 9079caf commit 475409c

File tree

7 files changed

+44
-34
lines changed

7 files changed

+44
-34
lines changed

mlir/include/mlir/Conversion/LLVMCommon/PrintCallHelper.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ namespace LLVM {
2323
/// Generate IR that prints the given string to stdout.
2424
/// If a custom runtime function is defined via `runtimeFunctionName`, it must
2525
/// have the signature void(char const*). The default function is `printString`.
26-
LogicalResult createPrintStrCall(OpBuilder &builder, Location loc, ModuleOp moduleOp,
27-
StringRef symbolName, StringRef string,
28-
const LLVMTypeConverter &typeConverter,
29-
bool addNewline = true,
30-
std::optional<StringRef> runtimeFunctionName = {});
26+
LogicalResult createPrintStrCall(
27+
OpBuilder &builder, Location loc, ModuleOp moduleOp, StringRef symbolName,
28+
StringRef string, const LLVMTypeConverter &typeConverter,
29+
bool addNewline = true, std::optional<StringRef> runtimeFunctionName = {});
3130
} // namespace LLVM
3231

3332
} // namespace mlir

mlir/include/mlir/Dialect/LLVMIR/FunctionCallUtils.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,26 @@ FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintOpenFn(Operation *moduleOp);
4949
FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintCloseFn(Operation *moduleOp);
5050
FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintCommaFn(Operation *moduleOp);
5151
FailureOr<LLVM::LLVMFuncOp> lookupOrCreatePrintNewlineFn(Operation *moduleOp);
52-
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateMallocFn(Operation *moduleOp, Type indexType);
52+
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateMallocFn(Operation *moduleOp,
53+
Type indexType);
5354
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateAlignedAllocFn(Operation *moduleOp,
54-
Type indexType);
55+
Type indexType);
5556
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateFreeFn(Operation *moduleOp);
5657
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateGenericAllocFn(Operation *moduleOp,
57-
Type indexType);
58-
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateGenericAlignedAllocFn(Operation *moduleOp,
59-
Type indexType);
58+
Type indexType);
59+
FailureOr<LLVM::LLVMFuncOp>
60+
lookupOrCreateGenericAlignedAllocFn(Operation *moduleOp, Type indexType);
6061
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateGenericFreeFn(Operation *moduleOp);
61-
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateMemRefCopyFn(Operation *moduleOp, Type indexType,
62-
Type unrankedDescriptorType);
62+
FailureOr<LLVM::LLVMFuncOp>
63+
lookupOrCreateMemRefCopyFn(Operation *moduleOp, Type indexType,
64+
Type unrankedDescriptorType);
6365

6466
/// Create a FuncOp with signature `resultType`(`paramTypes`)` and name `name`.
6567
/// Return a failure if the FuncOp found has unexpected signature.
66-
FailureOr<LLVM::LLVMFuncOp> lookupOrCreateFn(Operation *moduleOp, StringRef name,
67-
ArrayRef<Type> paramTypes = {},
68-
Type resultType = {}, bool isVarArg = false,
69-
bool isReserved = false);
68+
FailureOr<LLVM::LLVMFuncOp>
69+
lookupOrCreateFn(Operation *moduleOp, StringRef name,
70+
ArrayRef<Type> paramTypes = {}, Type resultType = {},
71+
bool isVarArg = false, bool isReserved = false);
7072

7173
} // namespace LLVM
7274
} // namespace mlir

mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,11 @@ struct AssertOpLowering : public ConvertOpToLLVMPattern<cf::AssertOp> {
6161

6262
// Failed block: Generate IR to print the message and call `abort`.
6363
Block *failureBlock = rewriter.createBlock(opBlock->getParent());
64-
if (LLVM::createPrintStrCall(rewriter, loc, module, "assert_msg", op.getMsg(),
65-
*getTypeConverter(), /*addNewLine=*/false,
66-
/*runtimeFunctionName=*/"puts").failed()) {
64+
if (LLVM::createPrintStrCall(rewriter, loc, module, "assert_msg",
65+
op.getMsg(), *getTypeConverter(),
66+
/*addNewLine=*/false,
67+
/*runtimeFunctionName=*/"puts")
68+
.failed()) {
6769
return failure();
6870
}
6971
if (abortOnFailedAssert) {

mlir/lib/Conversion/LLVMCommon/Pattern.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ LogicalResult ConvertToLLVMPattern::copyUnrankedDescriptors(
299299
// Allocate memory, copy, and free the source if necessary.
300300
Value memory =
301301
toDynamic
302-
? builder.create<LLVM::CallOp>(loc, mallocFunc.value(), allocationSize)
302+
? builder
303+
.create<LLVM::CallOp>(loc, mallocFunc.value(), allocationSize)
303304
.getResult()
304305
: builder.create<LLVM::AllocaOp>(loc, getVoidPtrType(),
305306
IntegerType::get(getContext(), 8),

mlir/lib/Conversion/LLVMCommon/PrintCallHelper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ LogicalResult mlir::LLVM::createPrintStrCall(
6060
Value gep =
6161
builder.create<LLVM::GEPOp>(loc, ptrTy, arrayTy, msgAddr, indices);
6262
if (auto printer =
63-
LLVM::lookupOrCreatePrintStringFn(moduleOp, runtimeFunctionName); succeeded(printer)) {
63+
LLVM::lookupOrCreatePrintStringFn(moduleOp, runtimeFunctionName);
64+
succeeded(printer)) {
6465
builder.create<LLVM::CallOp>(loc, TypeRange(),
6566
SymbolRefAttr::get(printer.value()), gep);
6667
} else {

mlir/lib/Conversion/MemRefToLLVM/AllocLikeConversion.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
using namespace mlir;
1616

1717
namespace {
18-
FailureOr<LLVM::LLVMFuncOp> getNotalignedAllocFn(const LLVMTypeConverter *typeConverter,
19-
Operation *module, Type indexType) {
18+
FailureOr<LLVM::LLVMFuncOp>
19+
getNotalignedAllocFn(const LLVMTypeConverter *typeConverter, Operation *module,
20+
Type indexType) {
2021
bool useGenericFn = typeConverter->getOptions().useGenericFunctions;
2122
if (useGenericFn)
2223
return LLVM::lookupOrCreateGenericAllocFn(module, indexType);
2324

2425
return LLVM::lookupOrCreateMallocFn(module, indexType);
2526
}
2627

27-
FailureOr<LLVM::LLVMFuncOp> getAlignedAllocFn(const LLVMTypeConverter *typeConverter,
28-
Operation *module, Type indexType) {
28+
FailureOr<LLVM::LLVMFuncOp>
29+
getAlignedAllocFn(const LLVMTypeConverter *typeConverter, Operation *module,
30+
Type indexType) {
2931
bool useGenericFn = typeConverter->getOptions().useGenericFunctions;
3032

3133
if (useGenericFn)
@@ -83,8 +85,10 @@ std::tuple<Value, Value> AllocationOpLLVMLowering::allocateBufferManuallyAlign(
8385
FailureOr<LLVM::LLVMFuncOp> allocFuncOp = getNotalignedAllocFn(
8486
getTypeConverter(), op->getParentWithTrait<OpTrait::SymbolTable>(),
8587
getIndexType());
86-
if (failed(allocFuncOp)) return std::make_tuple(Value(), Value());
87-
auto results = rewriter.create<LLVM::CallOp>(loc, allocFuncOp.value(), sizeBytes);
88+
if (failed(allocFuncOp))
89+
return std::make_tuple(Value(), Value());
90+
auto results =
91+
rewriter.create<LLVM::CallOp>(loc, allocFuncOp.value(), sizeBytes);
8892

8993
Value allocatedPtr =
9094
castAllocFuncResult(rewriter, loc, results.getResult(), memRefType,
@@ -150,7 +154,8 @@ Value AllocationOpLLVMLowering::allocateBufferAutoAlign(
150154
FailureOr<LLVM::LLVMFuncOp> allocFuncOp = getAlignedAllocFn(
151155
getTypeConverter(), op->getParentWithTrait<OpTrait::SymbolTable>(),
152156
getIndexType());
153-
if (failed(allocFuncOp)) return Value();
157+
if (failed(allocFuncOp))
158+
return Value();
154159
auto results = rewriter.create<LLVM::CallOp>(
155160
loc, allocFuncOp.value(), ValueRange({allocAlignment, sizeBytes}));
156161

mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,14 +180,14 @@ mlir::LLVM::lookupOrCreatePrintNewlineFn(Operation *moduleOp) {
180180
FailureOr<LLVM::LLVMFuncOp>
181181
mlir::LLVM::lookupOrCreateMallocFn(Operation *moduleOp, Type indexType) {
182182
return lookupOrCreateReservedFn(moduleOp, kMalloc, indexType,
183-
getVoidPtr(moduleOp->getContext()));
183+
getVoidPtr(moduleOp->getContext()));
184184
}
185185

186186
FailureOr<LLVM::LLVMFuncOp>
187187
mlir::LLVM::lookupOrCreateAlignedAllocFn(Operation *moduleOp, Type indexType) {
188188
return lookupOrCreateReservedFn(moduleOp, kAlignedAlloc,
189-
{indexType, indexType},
190-
getVoidPtr(moduleOp->getContext()));
189+
{indexType, indexType},
190+
getVoidPtr(moduleOp->getContext()));
191191
}
192192

193193
FailureOr<LLVM::LLVMFuncOp>
@@ -200,15 +200,15 @@ mlir::LLVM::lookupOrCreateFreeFn(Operation *moduleOp) {
200200
FailureOr<LLVM::LLVMFuncOp>
201201
mlir::LLVM::lookupOrCreateGenericAllocFn(Operation *moduleOp, Type indexType) {
202202
return lookupOrCreateReservedFn(moduleOp, kGenericAlloc, indexType,
203-
getVoidPtr(moduleOp->getContext()));
203+
getVoidPtr(moduleOp->getContext()));
204204
}
205205

206206
FailureOr<LLVM::LLVMFuncOp>
207207
mlir::LLVM::lookupOrCreateGenericAlignedAllocFn(Operation *moduleOp,
208208
Type indexType) {
209209
return lookupOrCreateReservedFn(moduleOp, kGenericAlignedAlloc,
210-
{indexType, indexType},
211-
getVoidPtr(moduleOp->getContext()));
210+
{indexType, indexType},
211+
getVoidPtr(moduleOp->getContext()));
212212
}
213213

214214
FailureOr<LLVM::LLVMFuncOp>

0 commit comments

Comments
 (0)