Page MenuHomePhabricator

[MLIR] Add complex addition and substraction to the standard dialect

Authored by frgossen on May 6 2020, 4:39 AM.



Complex addition and substraction are the first two binary operations on complex
Remaining operations will follow the same pattern.

Diff Detail

Event Timeline

frgossen created this revision.May 6 2020, 4:39 AM
Herald added a project: Restricted Project. · View Herald Transcript
rriddle resigned from this revision.May 6 2020, 11:04 AM
pifon2a accepted this revision.May 6 2020, 11:26 PM
pifon2a added inline comments.

@ftynse Alex, do you know if there is a need for arithmetic ops for complex<integer_type>? If yes, how should we call this one? AddCFOp? :)

This revision is now accepted and ready to land.May 6 2020, 11:26 PM
ftynse accepted this revision.May 7 2020, 12:36 AM
ftynse added inline comments.

I don't see an immediate need, but, e.g., C++ supports complex<int>.
Independently, addc is "add and carry" on x86.


Nit: drop the extra whitespace before ::


I wonder if it wouldn't be better to just have a helper function that returns something like

struct PairOfComplex {
  Value lhsReal, lhsImag, rhsReal, rhsImag;
template <typename OpTy> PairOfComplex extractComplexComponents(OpTy op);

that you would call from two individual patterns. Feels like it would be less code and less concepts in the code.

frgossen updated this revision to Diff 262846.May 8 2020, 2:51 AM
frgossen marked 4 inline comments as done.

Extract operands in helper function.

This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.May 27 2020, 12:04 PM

I would prefer you just use std::complex<Value> instead.


Side note, why is ConvertOpToLLVMPattern even templated if it doesn't do this for you? We should fix that,

mehdi_amini added inline comments.Jun 5 2020, 1:27 AM

@frgossen: ping?

Herald added a project: Restricted Project. · View Herald TranscriptJun 5 2020, 1:27 AM
Herald added a subscriber: msifontes. · View Herald Transcript
frgossen marked 3 inline comments as done.Jun 12 2020, 4:56 AM

Comments addressed in