Skip to content

Commit 0a4db2f

Browse files
committed
builder: return the operation type from the create method
This closes the door to on-the-fly folding, but that's unlikely to apply to dialect ops any time soon. If it does, we could add a new createFold method.
1 parent c19a840 commit 0a4db2f

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

example/ExampleMain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ void createFunctionExample(Module &module, const Twine &name) {
107107
Value *y3 = b.create<xd::ExtractElementOp>(y1, b.getInt32(2));
108108
Value *y4 = b.CreateAdd(y2, y3);
109109
Value *y5 = b.create<xd::InsertElementOp>(q2, y4, x1);
110-
Value *y6 = b.create<xd::InsertElementOp>(y5, y2, b.getInt32(5));
110+
auto *y6 = b.create<xd::InsertElementOp>(y5, y2, b.getInt32(5));
111111
b.create<xd::WriteOp>(y6);
112112

113-
cast<xd::InsertElementOp>(y6)->setIndex(b.getInt32(1));
113+
y6->setIndex(b.getInt32(1));
114114

115115
Value *p1 = b.create<xd::ReadOp>(b.getPtrTy(0));
116116
Value *p2 = b.create<xd::StreamAddOp>(p1, b.getInt64(14), b.getInt8(0));

include/llvm-dialects/Dialect/Builder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class Builder : public llvm::IRBuilder<> {
4141
template <typename DialectT>
4242
DialectT& getDialect() const {return m_dialects.getDialect<DialectT>();}
4343

44-
template <typename Op, typename ...Args>
45-
llvm::Instruction *create(Args&&... args) {
44+
template <typename Op, typename... Args> Op *create(Args &&...args) {
4645
Op *op = Op::create(*this, std::forward<Args>(args)...);
4746
assert(runInstructionVerifier([op](llvm::raw_ostream &errs) {
4847
return op->verifier(errs);

0 commit comments

Comments
 (0)