Skip to content

Commit 95e5b4d

Browse files
author
Thomas Symalla
committed
Add comments about arguments to op declarations
1 parent 50260f8 commit 95e5b4d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

lib/TableGen/GenDialect.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ class Builder;
180180
if (!op.description.empty())
181181
description += createCommentFromString(op.description);
182182

183+
if (op.getNumFullArguments() > 0) {
184+
description += "/// Arguments\n";
185+
for (const auto &[idx, arg] : llvm::enumerate(op.getFullArguments()))
186+
description += "/// " + arg.type->getBuilderCppType().str() + " " +
187+
arg.name + "\n";
188+
}
189+
183190
out << tgfmt(R"(
184191
$2
185192
class $_op : public $0 {

test/example/generated/ExampleDialect.h.inc

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ Initial = 2,
117117
/// For those times when you want a little extra, this operation adds two
118118
/// numbers and puts a constant on top.
119119
///
120+
/// Arguments
121+
/// ::llvm::Value * lhs
122+
/// ::llvm::Value * rhs
123+
/// uint32_t extra
120124

121125
class Add32Op : public ::llvm::CallInst {
122126
static const ::llvm::StringLiteral s_name; //{"xd.ir.add32"};
@@ -154,6 +158,9 @@ Extra = 2,
154158
///
155159
/// Longer description of... well, you know by now how this goes.
156160
///
161+
/// Arguments
162+
/// ::llvm::Value * lhs
163+
/// ::llvm::Value * rhs
157164

158165
class CombineOp : public ::llvm::CallInst {
159166
static const ::llvm::StringLiteral s_name; //{"xd.ir.combine"};
@@ -188,6 +195,9 @@ Rhs = 1,
188195
///
189196
/// Return the element of `vector` with the given `index`.
190197
///
198+
/// Arguments
199+
/// ::llvm::Value * vector
200+
/// ::llvm::Value * index
191201

192202
class ExtractElementOp : public ::llvm::CallInst {
193203
static const ::llvm::StringLiteral s_name; //{"xd.ir.extractelement"};
@@ -222,6 +232,8 @@ Index = 1,
222232
///
223233
/// Demonstrate a more complex unification case.
224234
///
235+
/// Arguments
236+
/// ::llvm::Value * source
225237

226238
class FromFixedVectorOp : public ::llvm::CallInst {
227239
static const ::llvm::StringLiteral s_name; //{"xd.ir.fromfixedvector"};
@@ -281,6 +293,8 @@ bool verifier(::llvm::raw_ostream &errs);
281293
/// Demonstrates the use of the same unevaluatable `le` predicate in a valued
282294
/// position.
283295
///
296+
/// Arguments
297+
/// ::llvm::Value * source
284298

285299
class IExtOp : public ::llvm::CallInst {
286300
static const ::llvm::StringLiteral s_name; //{"xd.ir.iext"};
@@ -312,6 +326,8 @@ Source = 0,
312326
///
313327
/// Demonstrates the use of a predicate in an unvalued position.
314328
///
329+
/// Arguments
330+
/// ::llvm::Value * source
315331

316332
class ITruncOp : public ::llvm::CallInst {
317333
static const ::llvm::StringLiteral s_name; //{"xd.ir.itrunc"};
@@ -343,6 +359,8 @@ Source = 0,
343359
///
344360
/// Make an argument immutable
345361
///
362+
/// Arguments
363+
/// bool val
346364

347365
class ImmutableOp : public ::llvm::CallInst {
348366
static const ::llvm::StringLiteral s_name; //{"xd.ir.immutable.op"};
@@ -372,6 +390,10 @@ Val = 0,
372390
/// Insert the given `value` into the given `vector` at the given `index` and
373391
/// returns the result.
374392
///
393+
/// Arguments
394+
/// ::llvm::Value * vector
395+
/// ::llvm::Value * value
396+
/// ::llvm::Value * index
375397

376398
class InsertElementOp : public ::llvm::CallInst {
377399
static const ::llvm::StringLiteral s_name; //{"xd.ir.insertelement"};
@@ -410,6 +432,9 @@ Index = 2,
410432
/// Like InstNameConflictOp but this has a second parameter named like the
411433
/// dialect compiler's first choice
412434
///
435+
/// Arguments
436+
/// ::llvm::Value * instName
437+
/// ::llvm::Value * instName_0
413438

414439
class InstNameConflictDoubleOp : public ::llvm::CallInst {
415440
static const ::llvm::StringLiteral s_name; //{"xd.ir.inst.name.conflict.double"};
@@ -446,6 +471,8 @@ InstName_0 = 1,
446471
/// value like IRBuilder methods. This op produces a conflict so the parameter
447472
/// will be renamed.
448473
///
474+
/// Arguments
475+
/// ::llvm::Value * instName
449476

450477
class InstNameConflictOp : public ::llvm::CallInst {
451478
static const ::llvm::StringLiteral s_name; //{"xd.ir.inst.name.conflict"};
@@ -612,6 +639,8 @@ bool verifier(::llvm::raw_ostream &errs);
612639
///
613640
/// Longer description of how this operation writes pieces of data.
614641
///
642+
/// Arguments
643+
/// ::llvm::Value * data
615644

616645
class SetWriteOp : public ::llvm::CallInst {
617646
static const ::llvm::StringLiteral s_name; //{"xd.ir.set.write"};
@@ -642,6 +671,8 @@ Data = 0,
642671
///
643672
/// Returns the store size of the given type in bytes.
644673
///
674+
/// Arguments
675+
/// ::llvm::Type * sizeof_type
645676

646677
class SizeOfOp : public ::llvm::CallInst {
647678
static const ::llvm::StringLiteral s_name; //{"xd.ir.sizeof"};
@@ -673,6 +704,10 @@ SizeofType = 0,
673704
///
674705
/// Illustrate the use of the OpClass feature.
675706
///
707+
/// Arguments
708+
/// ::llvm::Value * ptr
709+
/// ::llvm::Value * count
710+
/// ::llvm::Value * initial
676711

677712
class StreamAddOp : public StreamReduceOp {
678713
static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.add"};
@@ -700,6 +735,10 @@ bool verifier(::llvm::raw_ostream &errs);
700735
///
701736
/// Illustrate the use of the OpClass feature.
702737
///
738+
/// Arguments
739+
/// ::llvm::Value * ptr
740+
/// ::llvm::Value * count
741+
/// ::llvm::Value * initial
703742

704743
class StreamMaxOp : public StreamReduceOp {
705744
static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.max"};
@@ -727,6 +766,10 @@ bool verifier(::llvm::raw_ostream &errs);
727766
///
728767
/// Illustrate the use of the OpClass feature.
729768
///
769+
/// Arguments
770+
/// ::llvm::Value * ptr
771+
/// ::llvm::Value * count
772+
/// ::llvm::Value * initial
730773

731774
class StreamMinOp : public StreamReduceOp {
732775
static const ::llvm::StringLiteral s_name; //{"xd.ir.stream.min"};
@@ -754,6 +797,8 @@ bool verifier(::llvm::raw_ostream &errs);
754797
///
755798
/// The argument should not have a setter method
756799
///
800+
/// Arguments
801+
/// ::llvm::StringRef val
757802

758803
class StringAttrOp : public ::llvm::CallInst {
759804
static const ::llvm::StringLiteral s_name; //{"xd.ir.string.attr.op"};
@@ -782,6 +827,8 @@ Val = 0,
782827
///
783828
/// Longer description of how this operation writes a piece of data.
784829
///
830+
/// Arguments
831+
/// ::llvm::Value * data
785832

786833
class WriteOp : public ::llvm::CallInst {
787834
static const ::llvm::StringLiteral s_name; //{"xd.ir.write"};
@@ -812,6 +859,9 @@ Data = 0,
812859
///
813860
/// Longer description of how this operation writes pieces of data.
814861
///
862+
/// Arguments
863+
/// ::llvm::Value * data
864+
/// ::llvm::ArrayRef<::llvm::Value *> args
815865

816866
class WriteVarArgOp : public ::llvm::CallInst {
817867
static const ::llvm::StringLiteral s_name; //{"xd.ir.write.vararg"};

0 commit comments

Comments
 (0)