Skip to content

Commit 808dfb8

Browse files
committedSep 8, 2015
[mips] Reserve address spaces 1-255 for software use.
Summary: And define them to have noop casts with address spaces 0-255. Reviewers: pekka.jaaskelainen Subscribers: pekka.jaaskelainen, llvm-commits Differential Revision: http://reviews.llvm.org/D12678 llvm-svn: 246990
1 parent d930ef7 commit 808dfb8

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
 

‎llvm/lib/Target/Mips/MipsISelLowering.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,14 @@ namespace llvm {
269269
unsigned getRegisterByName(const char* RegName, EVT VT,
270270
SelectionDAG &DAG) const override;
271271

272+
/// Returns true if a cast between SrcAS and DestAS is a noop.
273+
bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override {
274+
// Mips doesn't have any special address spaces so we just reserve
275+
// the first 256 for software use (e.g. OpenCL) and treat casts
276+
// between them as noops.
277+
return SrcAS < 256 && DestAS < 256;
278+
}
279+
272280
protected:
273281
SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
274282

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: llc < %s -march=mips -mcpu=mips2 | FileCheck %s -check-prefix=ALL
2+
3+
; Address spaces 1-255 are software defined.
4+
define i32* @cast(i32 *%arg) {
5+
%1 = addrspacecast i32* %arg to i32 addrspace(1)*
6+
%2 = addrspacecast i32 addrspace(1)* %1 to i32 addrspace(2)*
7+
%3 = addrspacecast i32 addrspace(2)* %2 to i32 addrspace(0)*
8+
ret i32* %3
9+
}
10+
11+
; ALL-LABEL: cast:
12+
; ALL: move $2, $4

0 commit comments

Comments
 (0)