[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:31 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 {
----------------
bharadwajy wrote:
> nit: I assume `rn` is `readnone`, it would be better to spell it out. Do we have cases where `fn_attr` needs to be a list?
>From `hctdb.py` it appears that only two "shorthand" strings viz., "rn" - meaning "does not access memory" and "ro" - meaning "only reads from memory", are valid. Will make appropriate changes to both restrict the accepted values and spell them out.
https://github.com/llvm/llvm-project/pull/80350
More information about the llvm-commits
mailing list