llvm / llvm/circt

[HWArith] Does it make sense to add an arithmetic negation unary op?

Open
#8,493 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

I've been reading https://circt.llvm.org/docs/Dialects/HWArith/RationaleHWArith/ and start to wonder if an arithmetic negation op also fits here?

Proposal for the type inference rules:

Operand type Result type
(U) ui<a> si<r>, r = a + 1
(S) si<a> si<r>, r = a + 1

This is essentially the existing subtraction rules with a == 0. But since it's said that 0-width values are not supported yet. Maybe it's useful to add arithmetic negation on its own?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the HWArith Rationale document and its existing subtraction rules, then review the proposed unsigned and signed type-inference cases. The issue names no implementation file or test; done would require a settled decision on whether unary arithmetic negation belongs in HWArith and an agreed implementation and verification plan.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.