)]}'
{
  "commit": "ed5b0e1e6986a652de8be88fa5ff92bf75c40a21",
  "tree": "30257b0fae34937bbb336a8a4e0b9c566948495b",
  "parents": [
    "53e87908c67f158bfe196a3c7cec690dc5eed1fc"
  ],
  "author": {
    "name": "Joshua Batista",
    "email": "jbatista@microsoft.com",
    "time": "Fri Aug 02 21:16:24 2024 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Aug 02 21:16:24 2024 -0700"
  },
  "message": "Add length builtins and length HLSL function to DirectX Backend (#101256)\n\nThis PR adds the length intrinsic and an HLSL function that uses it.\r\nThe SPIRV implementation is left for a future PR.\r\nThis PR addresses #99134, though some SPIR-V changes still need to be\r\nmade to complete the task. Below is how this PR addresses #99134.\r\n- \"Implement `length` clang builtin\" was done by defining `HLSLL ength`\r\nin Builtins.td\r\n- \"Link `length` clang builtin with hlsl_intrinsics.h\" was done by using\r\nthe alias attribute to make `length` an alias of\r\n`__builtin_hlsl_elementwise_length` in hlsl_intrinsics.h\r\n- \"Add sema checks for `length` to `CheckHLSLBuiltinFunctionCall` in\r\n`SemaChecking.cpp` \" was done, but in this case not in SemaChecking.cpp,\r\nrather SemaHLSL.cpp. A case was added to the builtin to check for\r\nsemantic failures, and set `TheCall` up to have the right return type.\r\n- \"Add codegen for `length` to `EmitHLSLBuiltinExpr` in `CGBuiltin.cpp`\"\r\nwas done. For scalars, fabs is emitted, otherwise, length is emitted.\r\n- \"Add codegen tests to `clang/test/CodeGenHLSL/builtins/length.hlsl`\r\nwas done to test that `length` in HLSL emits the right intrinsic.\r\n- \"Add sema tests to `clang/test/SemaHLSL/BuiltIns/length-errors.hlsl`\"\r\nwas done to test for diagnostics emitted in SemaHLSL.cpp\r\n- \"Create the `int_dx_length` intrinsic in `IntrinsicsDirectX.td`\" was\r\ndone. Specifying return types and parameter types was difficult, but\r\n`idot` was used for reference, and `llvm\\include\\llvm\\IR\\Intrinsics.td`\r\ncontains all the ways to express return / parameter types.\r\n- \"Create an intrinsic expansion of `int_dx_length` in\r\n`llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp`\" was done, and was\r\nmostly derived by looking at `TranslateLength` in `HLOperationLower.cpp`\r\nin the DXC codebase.\r\n- \"Create the `length.ll` and `length_errors.ll` tests in\r\n`llvm/test/CodeGen/DirectX/`\" was done by taking the DXIL output of\r\n`clang/test/CodeGenHLSL/builtins/length.hlsl` and running `opt -S\r\n-dxil-intrinsic-expansion` and ` opt -S -dxil-op-lower` on it, checking\r\nfor how the length intrinsic was either expanded or lowered.\r\n- \"Create the `int_spv_length` intrinsic in `IntrinsicsSPIRV.td`\" was\r\ndone by copying `IntrinsicsDirectX.td`.\r\n\r\n---------\r\n\r\nCo-authored-by: Justin Bogner \u003cmail@justinbogner.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "ccddeb9396284d17c7ce8820be00f4ca06ab2e27",
      "old_mode": 33188,
      "old_path": "clang/include/clang/Basic/Builtins.td",
      "new_id": "b025a7681bfac3c9526fd5ee44235fc631b37193",
      "new_mode": 33188,
      "new_path": "clang/include/clang/Basic/Builtins.td"
    },
    {
      "type": "modify",
      "old_id": "3221989e14351f5b76fcc48e363f8925125e2bfe",
      "old_mode": 33188,
      "old_path": "clang/lib/CodeGen/CGBuiltin.cpp",
      "new_id": "13caab6c421119a8d40f3257192df260829e5724",
      "new_mode": 33188,
      "new_path": "clang/lib/CodeGen/CGBuiltin.cpp"
    },
    {
      "type": "modify",
      "old_id": "8c067f496395568ca787aa3b60b8b077e9cea757",
      "old_mode": 33188,
      "old_path": "clang/lib/CodeGen/CGHLSLRuntime.h",
      "new_id": "3f2dc0ae7b84ded78e540f3a1d6d8836ad918b04",
      "new_mode": 33188,
      "new_path": "clang/lib/CodeGen/CGHLSLRuntime.h"
    },
    {
      "type": "modify",
      "old_id": "6d86d278bc711c4bd2c1c1e1dd40ea21f27bab93",
      "old_mode": 33188,
      "old_path": "clang/lib/Headers/hlsl/hlsl_intrinsics.h",
      "new_id": "e35a5262f9280949559c964a57a37aeebc41c190",
      "new_mode": 33188,
      "new_path": "clang/lib/Headers/hlsl/hlsl_intrinsics.h"
    },
    {
      "type": "modify",
      "old_id": "7724fafb253c5868f803dd9577232fab79d712a2",
      "old_mode": 33188,
      "old_path": "clang/lib/Sema/SemaHLSL.cpp",
      "new_id": "a9c0c57e88221d9f89b76ddc06fc3219f9138c65",
      "new_mode": 33188,
      "new_path": "clang/lib/Sema/SemaHLSL.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "1c23b0df04df9873629f696f54a9ed5cc47037a7",
      "new_mode": 33188,
      "new_path": "clang/test/CodeGenHLSL/builtins/length.hlsl"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "fe0046a2ab5a1ed8cb151dc210c17c23c3d8e99d",
      "new_mode": 33188,
      "new_path": "clang/test/SemaHLSL/BuiltIns/length-errors.hlsl"
    },
    {
      "type": "modify",
      "old_id": "a7f212da2f5b63a7840af87831857ce4ea13e87a",
      "old_mode": 33188,
      "old_path": "llvm/include/llvm/IR/IntrinsicsDirectX.td",
      "new_id": "312c3862f240d88a9b9ea860a36c6259c46bf737",
      "new_mode": 33188,
      "new_path": "llvm/include/llvm/IR/IntrinsicsDirectX.td"
    },
    {
      "type": "modify",
      "old_id": "ef6ddf12c32f6837063c3a915c66365ade2abb92",
      "old_mode": 33188,
      "old_path": "llvm/include/llvm/IR/IntrinsicsSPIRV.td",
      "new_id": "3f77ef6bfcdbe23f7d63edd325797fda00de40c5",
      "new_mode": 33188,
      "new_path": "llvm/include/llvm/IR/IntrinsicsSPIRV.td"
    },
    {
      "type": "modify",
      "old_id": "4b162a35365c8e532eac65fdc96d411128bbc9dd",
      "old_mode": 33188,
      "old_path": "llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp",
      "new_id": "ac85859af8a53e36cb178b01627ae9e4d1a8cf98",
      "new_mode": 33188,
      "new_path": "llvm/lib/Target/DirectX/DXILIntrinsicExpansion.cpp"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "d12fcf4722a07bcf7ed5803da65d445ef0854e07",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/DirectX/length.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "952c9155b25998fa7ee162a6d27dc245fb51be48",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/DirectX/length_error.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "277fbaa462b0faf87bc6abf522fbd5bce571793a",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/DirectX/length_invalid_intrinsic_error.ll"
    },
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "ac3a0513eb6b27bfa3e038041ea85cc3f3e17b1c",
      "new_mode": 33188,
      "new_path": "llvm/test/CodeGen/DirectX/length_invalid_intrinsic_error_scalar.ll"
    }
  ]
}
