Skip to content

Commit 3a1bbd0

Browse files
committed
fix comment format
1 parent f35d385 commit 3a1bbd0

2 files changed

Lines changed: 29 additions & 29 deletions

File tree

include/NeuraDialect/NeuraOps.td

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ def Neura_DataMovOp : Op<NeuraDialect, "data_mov"> {
312312
// ----------------------------------------------------
313313
// Defines ctrl-related operations.
314314

315-
// Phi operation for merging values in dataflow form
315+
// Defines phi operation for merging values in dataflow form.
316316
def Neura_PhiOp : Op<NeuraDialect, "phi"> {
317317
let summary = "Phi node in dataflow form";
318318
let description = [{
@@ -328,11 +328,11 @@ def Neura_PhiOp : Op<NeuraDialect, "phi"> {
328328
let arguments = (ins Variadic<AnyType>:$inputs);
329329
let results = (outs AnyType:$result);
330330

331-
// Explicitly specify types for operands in the assembly format
331+
// Explicitly specifies types for operands in the assembly format.
332332
// let assemblyFormat = "$init_val `:` type($init_val) `,` $loop_val `:` type($loop_val) attr-dict `,` type($result)";
333333
}
334334

335-
// Control movement extending base move but with different signature.
335+
// Defines control movement extending base move but with different signature.
336336
def Neura_CtrlMovOp : Op<NeuraDialect, "ctrl_mov"> {
337337
let summary = "Control movement operation";
338338
let description = [{
@@ -343,15 +343,15 @@ def Neura_CtrlMovOp : Op<NeuraDialect, "ctrl_mov"> {
343343
ctrl_mov %value to %placeholder : f32 // Connect value to placeholder
344344
}];
345345

346-
// Add type constraints for both operands
346+
// Adds type constraints for both operands.
347347
let arguments = (ins AnyType:$value, AnyType:$target);
348348
let results = (outs);
349349

350-
// Correct assembly format - types must be space-separated
350+
// Corrects assembly format - types must be space-separated.
351351
let assemblyFormat = "$value `->` $target attr-dict `:` type($value) type($target)";
352352
}
353353

354-
// Reserve operation for control flow values.
354+
// Defines reserve operation for control flow values.
355355
def Neura_ReserveOp : Op<NeuraDialect, "reserve"> {
356356
let summary = "Creates a placeholder for control flow values";
357357
let description = [{
@@ -438,7 +438,7 @@ def Neura_LoopControlOp : Op<NeuraDialect, "loop_control">{
438438
predicate bit is initially 0, while the start value's predicate bit is 1.
439439

440440
Example:
441-
// Loop control that calculates next index and validity in one step
441+
// Shows loop control that calculates next index and validity in one step.
442442
%next_idx, %loop_valid = neura.loop_control(
443443
parent_valid = %parent_valid,
444444
start = %start_val,

lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct LlvmFAddToNeuraFAdd : public OpRewritePattern<mlir::LLVM::FAddOp> {
5252
if (!mlir::isa<FloatType>(result_type))
5353
return failure();
5454

55-
// Optional predicate: default to 'none'
55+
// Sets optional predicate: default to 'none'.
5656
rewriter.replaceOpWithNewOp<neura::FAddOp>(op, result_type, lhs, rhs);
5757
return success();
5858
}
@@ -72,7 +72,7 @@ struct LlvmFSubToNeuraFSub : public OpRewritePattern<mlir::LLVM::FSubOp> {
7272
return failure();
7373
}
7474

75-
// Optional predicate: default to 'none'.
75+
// Sets optional predicate: default to 'none'.
7676
rewriter.replaceOpWithNewOp<neura::FSubOp>(op, result_type, lhs, rhs,
7777
Value());
7878
return success();
@@ -291,13 +291,13 @@ struct LlvmConstantToNeuraConstant : public OpRewritePattern<LLVM::ConstantOp> {
291291
PatternRewriter &rewriter) const override {
292292
auto attr = op.getValue();
293293

294-
// Creates operation state manually
294+
// Creates operation state manually.
295295
OperationState state(op.getLoc(), neura::ConstantOp::getOperationName());
296296
state.addAttribute("value", attr);
297297
state.addAttribute("predicate", rewriter.getBoolAttr(true));
298298
state.addTypes(op.getType());
299299

300-
// Creates the operation and replace
300+
// Creates the operation and replaces.
301301
Operation *newOp = rewriter.create(state);
302302
rewriter.replaceOp(op, newOp->getResults());
303303
return success();
@@ -312,9 +312,9 @@ struct LlvmAllocaToNeuraAlloca : public OpRewritePattern<LLVM::AllocaOp> {
312312
Value size = op.getArraySize();
313313
Type resultType = op.getType();
314314

315-
// Convert the size to neura.data<i32, i1> if it's not already
316-
// For simplicity, we'll assume the size is already in the right format
317-
// In practice, you might need to handle type conversion here
315+
// Converts the size to neura.data<i32, i1> if it's not already.
316+
// Assumes the size is already in the right format.
317+
// Handles type conversion here.
318318

319319
rewriter.replaceOpWithNewOp<neura::AllocaOp>(op, resultType, size);
320320
return success();
@@ -373,20 +373,20 @@ struct LlvmFuncToNeuraFunc : public OpRewritePattern<LLVM::LLVMFuncOp> {
373373
return failure();
374374
}
375375

376-
// Convert LLVMFunctionType to FunctionType
376+
// Converts LLVMFunctionType to FunctionType.
377377
auto llvmFuncType = op.getFunctionType();
378378
auto funcType = rewriter.getFunctionType(
379379
llvmFuncType.getParams(),
380380
llvmFuncType.getReturnType()
381381
);
382382

383-
// Create the new func.func operation using OperationState to have full control
383+
// Creates the new func.func operation using OperationState to have full control.
384384
OperationState state(op.getLoc(), func::FuncOp::getOperationName());
385385
state.addAttribute("sym_name", rewriter.getStringAttr(op.getName()));
386386
state.addAttribute("function_type", TypeAttr::get(funcType));
387387

388-
// Copy ALL attributes from the original llvm.func exactly as they are
389-
// Skip function type and name attributes as they are handled separately
388+
// Copies ALL attributes from the original llvm.func exactly as they are.
389+
// Skips function type and name attributes as they are handled separately.
390390
SmallVector<NamedAttribute> attrs;
391391
for (auto attr : op->getAttrs()) {
392392
if (attr.getName() == "function_type" || attr.getName() == "sym_name") {
@@ -396,15 +396,15 @@ struct LlvmFuncToNeuraFunc : public OpRewritePattern<LLVM::LLVMFuncOp> {
396396
}
397397
state.addAttributes(attrs);
398398

399-
// Add the function body region
399+
// Adds the function body region.
400400
state.addRegion();
401401

402402
auto newFunc = cast<func::FuncOp>(rewriter.create(state));
403403

404-
// Move the function body
404+
// Moves the function body.
405405
rewriter.inlineRegionBefore(op.getBody(), newFunc.getBody(), newFunc.getBody().end());
406406

407-
// Replace the old function
407+
// Replaces the old function.
408408
rewriter.replaceOp(op, newFunc);
409409
return success();
410410
}
@@ -415,7 +415,7 @@ struct LlvmCallToFuncCall : public OpRewritePattern<LLVM::CallOp> {
415415

416416
LogicalResult matchAndRewrite(LLVM::CallOp op,
417417
PatternRewriter &rewriter) const override {
418-
// Get the callee name
418+
// Gets the callee name.
419419
auto callee = op.getCallee();
420420
if (!callee) {
421421
return failure();
@@ -427,22 +427,22 @@ struct LlvmCallToFuncCall : public OpRewritePattern<LLVM::CallOp> {
427427
return failure();
428428
}
429429

430-
// Look for a func.func with the same name
430+
// Looks for a func.func with the same name.
431431
func::FuncOp funcOp = module.lookupSymbol<func::FuncOp>(callee.value());
432432
if (!funcOp) {
433433
return failure();
434434
}
435435

436-
// Get the result types from the function signature
436+
// Gets the result types from the function signature.
437437
auto resultTypes = funcOp.getFunctionType().getResults();
438438

439-
// Convert the call to func.call
439+
// Converts the call to func.call.
440440
auto newCall = rewriter.create<func::CallOp>(
441441
op.getLoc(), resultTypes, callee.value(), op.getArgOperands()
442442
);
443443

444-
// Replace the old call with the new one
445-
// Handle both cases: calls with results and calls without results
444+
// Replaces the old call with the new one.
445+
// Handles both cases: calls with results and calls without results.
446446
if (op.getNumResults() == 0) {
447447
rewriter.eraseOp(op);
448448
} else {
@@ -499,13 +499,13 @@ struct LowerLlvmToNeuraPass
499499

500500
ModuleOp module_op = getOperation();
501501

502-
// function-level conversions
502+
// Performs function-level conversions.
503503
if (failed(applyPatternsGreedily(module_op, frozen))) {
504504
signalPassFailure();
505505
return;
506506
}
507507

508-
// operation-level conversions
508+
// Performs operation-level conversions.
509509
// Applies to every region inside the module (regardless of func type,
510510
// e.g., mlir func or llvm func).
511511
module_op.walk([&](FunctionOpInterface func) {

0 commit comments

Comments
 (0)