This adds operations for binary additive operators to EmitC. The input
arguments to these ops can be EmitC pointers and thus the operations can
be used for pointer arithmetic.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Updating D149963: [mlir][emitc] Add add and sub operations
Extend verifier to check emitc.sub result type.
Updating D149963: [mlir][emitc] Add add and sub operations
Adds a base class for binary arithmetic operations and a custom assembly format.
Updating D149963: [mlir][emitc] Add add and sub operations
Harmonize naming in the emitter.
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | ||
---|---|---|
40 | Is this really an add? Meaning, this would also allow to represent "adding" two classes. Why not operator_plus op that correspond to the form without adding any connotation with arithmetic? (the verifier could still flag illegal pointer usage, but don't know if we need commutative or will be doing arithmetic level optimizations here). | |
51 | I'd be more interested in seeing what the resultant output is rather than custom and generic. |
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | ||
---|---|---|
40 | Indeed, adding two !emitc.opaque types could result in adding two classes. According to https://en.cppreference.com/w/cpp/language/operator_arithmetic the operator name of + is addition. But we can rename to operator_plus, no strong feelings here. Commutative could be skipped. | |
51 | You mean the generated C/C++ code added as example here? |
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | ||
---|---|---|
40 | Good point (I was going off https://en.wikipedia.org/wiki/List_of_typographical_symbols_and_punctuation_marks and structural representation). Given C++ language already calls the operator that, I'd be fine with it (add, operator_add - probably doesn't make a difference as we'll never have both, so shorter is good). But yes lets drop commutative. | |
51 | Yes, the generic form seems not specific to the op. |
mlir/include/mlir/Dialect/EmitC/IR/EmitC.td | ||
---|---|---|
51 | I've added the generated code accordingly. |
Is this really an add? Meaning, this would also allow to represent "adding" two classes. Why not operator_plus op that correspond to the form without adding any connotation with arithmetic? (the verifier could still flag illegal pointer usage, but don't know if we need commutative or will be doing arithmetic level optimizations here).