Skip to content

Commit

Permalink
Merging r246990:
Browse files Browse the repository at this point in the history
------------------------------------------------------------------------
r246990 | dsanders | 2015-09-08 10:07:03 +0100 (Tue, 08 Sep 2015) | 9 lines

[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: 247538
  • Loading branch information
dsandersllvm committed Sep 14, 2015
1 parent 08215c1 commit 7b9c7b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions llvm/lib/Target/Mips/MipsISelLowering.h
Expand Up @@ -269,6 +269,14 @@ namespace llvm {
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;

Expand Down
12 changes: 12 additions & 0 deletions llvm/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

0 comments on commit 7b9c7b8

Please sign in to comment.