Skip to content

waveasm: add more ops#1055

Open
willghatch wants to merge 1 commit intomainfrom
users/willghatch/waveasm-if-and-ops
Open

waveasm: add more ops#1055
willghatch wants to merge 1 commit intomainfrom
users/willghatch/waveasm-if-and-ops

Conversation

@willghatch
Copy link
Contributor

Mostly scf.if.

Stuff towards getting dynamic mxfp4 working. This was the main piece to get a simple example compiling but not passing. Just adopts the loop handling for register liveness, which will not be enough, but was the simplest thing to split this off.

Not clear how useful this is until I actually get stuff working on top of it, but this passes the basic tests.

Mostly scf.if.

Stuff towards getting dynamic mxfp4 working.  This was the main piece to get a simple example compiling but not passing.  Just adopts the loop handling for register liveness, which will not be enough, but was the simplest thing to split this off.
auto loc = op->getLoc();

int32_t mask = 0;
if (auto maskAttr = op->getAttrOfType<IntegerAttr>("mask")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally I'd expect the function to take an op of a specific type, or at least to cast and use a named accessor.

ctx.getMapper().mapValue(loadOp.getResult(), loadInstr.getResult(0));

Type elemType = memrefType.getElementType();
int64_t elemBytes = (elemType.getIntOrFloatBitWidth() + 7) / 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this intends to do a ceilDiv, llvm has a function for that.

for (Region &region : regionOp->getRegions()) {
for (Block &block : region) {
Operation *terminator = block.getTerminator();
if (terminator) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, getTerminator will assert if the block does not have a terminator so its result should never be null, but may be worth doubl-checking.

return;

auto &thenBlock = ifOp.getThenBlock();
auto thenYield = dyn_cast<YieldOp>(thenBlock.getTerminator());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cast, the terminator of an if is guaranteed to be a yield.

elseYield = dyn_cast<YieldOp>(elseBlock->getTerminator());
}

for (unsigned i = 0; i < ifOp->getNumResults(); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

llvm::SmallVector<Value> members;
members.push_back(ifResult);

if (i < thenYield.getResults().size()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (i < thenYield.getResults().size()) {
if (i < thenYield->getNumResults()) {

Comment on lines +3 to +4
// Test: scf.if translation to waveasm.if, including result type propagation
// from then-yield operands and else-branch type matching.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the type propagation checked?

@@ -0,0 +1,110 @@
// RUN: waveasm-translate --disable-pass-verifier --waveasm-linear-scan %s 2>&1 | FileCheck %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this and other tests actually need the (non-portable) 2>&1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants