[PATCH] D12678: [mips] Reserve address spaces 1-255 for software use.
Daniel Sanders via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 7 09:43:05 PDT 2015
dsanders created this revision.
dsanders added subscribers: llvm-commits, pekka.jaaskelainen.
And define them to have noop casts with address spaces 0-255.
http://reviews.llvm.org/D12678
Files:
lib/Target/Mips/MipsISelLowering.h
test/CodeGen/Mips/llvm-ir/addrspacecast.ll
Index: test/CodeGen/Mips/llvm-ir/addrspacecast.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/llvm-ir/addrspacecast.ll
@@ -0,0 +1,12 @@
+; RUN: llc < %s -march=mips -mcpu=mips2 | FileCheck %s -check-prefix=ALL
+
+; Address spaces 1-255 are software defined.
+define i32* @cast(i32 *%arg) {
+ %1 = addrspacecast i32* %arg to i32 addrspace(1)*
+ %2 = addrspacecast i32 addrspace(1)* %1 to i32 addrspace(2)*
+ %3 = addrspacecast i32 addrspace(2)* %2 to i32 addrspace(0)*
+ ret i32* %3
+}
+
+; ALL-LABEL: cast:
+; ALL: move $2, $4
Index: lib/Target/Mips/MipsISelLowering.h
===================================================================
--- lib/Target/Mips/MipsISelLowering.h
+++ lib/Target/Mips/MipsISelLowering.h
@@ -269,6 +269,14 @@
unsigned getRegisterByName(const char* RegName, EVT VT,
SelectionDAG &DAG) const override;
+ /// Returns true if a cast between SrcAS and DestAS is a noop.
+ bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
+ // Mips doesn't have any special address spaces so we just reserve
+ // the first 256 for software use (e.g. OpenCL) and treat casts
+ // between them as noops.
+ return SrcAS < 256 && DestAS < 256;
+ }
+
protected:
SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12678.34165.patch
Type: text/x-patch
Size: 1396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150907/79864351/attachment.bin>
More information about the llvm-commits
mailing list