[llvm] 6780ab3 - [Hexagon] Add support for addrspacecast lowering (#119195)

via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 20 09:20:42 PST 2024


Author: Santanu Das
Date: 2024-12-20T11:20:37-06:00
New Revision: 6780ab371ff8ce5e2b08b5fddd75a8296d3debdd

URL: https://github.com/llvm/llvm-project/commit/6780ab371ff8ce5e2b08b5fddd75a8296d3debdd
DIFF: https://github.com/llvm/llvm-project/commit/6780ab371ff8ce5e2b08b5fddd75a8296d3debdd.diff

LOG: [Hexagon] Add support for addrspacecast lowering (#119195)

This patch adds support for addrspacecast lowering. At the moment, there
are no separate address spaces for Hexagon target, hence this
instruction is treated as a noop.

Added: 
    llvm/test/CodeGen/Hexagon/addrspacecast-crash.ll

Modified: 
    llvm/lib/Target/Hexagon/HexagonTargetMachine.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
index 6438d0d5a6ba84..65f5b6e7e8eb7f 100644
--- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
+++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.h
@@ -46,6 +46,10 @@ class HexagonTargetMachine : public CodeGenTargetMachineImpl {
   MachineFunctionInfo *
   createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
                             const TargetSubtargetInfo *STI) const override;
+
+  bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
+    return true;
+  }
 };
 
 } // end namespace llvm

diff  --git a/llvm/test/CodeGen/Hexagon/addrspacecast-crash.ll b/llvm/test/CodeGen/Hexagon/addrspacecast-crash.ll
new file mode 100644
index 00000000000000..ce197bdeea1f38
--- /dev/null
+++ b/llvm/test/CodeGen/Hexagon/addrspacecast-crash.ll
@@ -0,0 +1,12 @@
+; Tests if addrspacecast is handled in Hexagon backend
+
+; REQUIRES: asserts
+
+; RUN: llc -march=hexagon %s -o /dev/null
+
+define double @f(ptr %G, ptr %x) {
+BB:
+  %Castaddrspacecast = addrspacecast ptr %x to ptr addrspace(1)
+  store ptr addrspace(1) %Castaddrspacecast, ptr %G, align 8
+  ret double 0.000000e+00
+}


        


More information about the llvm-commits mailing list