[llvm] [DirectX] Add support to lower LLVM intrinsics ceil, cos, fabs, and floor to DXIL Ops. (PR #80350)
S. Bharadwaj Yadavalli via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 7 08:57:44 PST 2024
================
@@ -86,57 +106,85 @@ class dxil_op<string name, int code_id, dxil_class code_class, dxil_category op_
let stats_group = _stats_group;
}
-// The intrinsic which map directly to this dxil op.
+class dxil_op_min<string _name, int code_id, string _doc> : dxil_inst {
+ let name = _name;
+ let dxil_op = _name;
+ let dxil_opid = code_id;
+ let doc = _doc;
+}
+
+
+// LLVM intrinsic to map dxil op to.
class dxil_map_intrinsic<Intrinsic llvm_intrinsic_> { Intrinsic llvm_intrinsic = llvm_intrinsic_; }
-def Sin : dxil_op<"Sin", 13, Unary, unary_float, "returns sine(theta) for theta in radians.",
- "half;float;", "rn",
- [
- dxil_param<0, "$o", "", "operation result">,
- dxil_param<1, "i32", "opcode", "DXIL opcode">,
- dxil_param<2, "$o", "value", "input value">
- ],
- ["floats"]>,
- dxil_map_intrinsic<int_sin>;
-
-def UMax :dxil_op< "UMax", 39, Binary, binary_uint, "unsigned integer maximum. UMax(a,b) = a > b ? a : b",
- "i16;i32;i64;", "rn",
- [
+// Unary class DXIL Ops
+let op_class = unary, ops = [
+ dxil_param<0, "$o", "", "operation result">,
+ dxil_param<1, "i32", "opcode", "DXIL opcode">,
+ dxil_param<2, "$o", "value", "input value">
+ ], fn_attr = "rn" in {
+ // Unary half/float DXIL Ops
+ let category = unary_float, oload_types = "hf", stats_group = ["floats"] in {
----------------
bharadwajy wrote:
> `hf` means we need overloads for `half` and `float` right? Can we make that a list too? It would be nice to have the tablegen be less arcane and more explicit. I also question if these should be a string or a list of Type objects as defined above. The advantage of the latter is that we allow TableGen to verify the correctness.
Agreed. Will make the suggested changes. Thanks!
https://github.com/llvm/llvm-project/pull/80350
More information about the llvm-commits
mailing list