[NVPTX] Add support for isspacep instruction

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211931 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Justin Holewinski 2014-06-27 18:35:24 +00:00
parent 1571d272c8
commit de7bbdff33
4 changed files with 93 additions and 0 deletions

View File

@ -889,6 +889,24 @@ def int_nvvm_compiler_error :
def int_nvvm_compiler_warn :
Intrinsic<[], [llvm_anyptr_ty], [], "llvm.nvvm.compiler.warn">;
// isspacep.{const, global, local, shared}
def int_nvvm_isspacep_const
: Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], [IntrNoMem],
"llvm.nvvm.isspacep.const">,
GCCBuiltin<"__nvvm_isspacep_const">;
def int_nvvm_isspacep_global
: Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], [IntrNoMem],
"llvm.nvvm.isspacep.global">,
GCCBuiltin<"__nvvm_isspacep_global">;
def int_nvvm_isspacep_local
: Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], [IntrNoMem],
"llvm.nvvm.isspacep.local">,
GCCBuiltin<"__nvvm_isspacep_local">;
def int_nvvm_isspacep_shared
: Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], [IntrNoMem],
"llvm.nvvm.isspacep.shared">,
GCCBuiltin<"__nvvm_isspacep_shared">;
// Environment register read
def int_nvvm_read_ptx_sreg_envreg0
: Intrinsic<[llvm_i32_ty], [], [IntrNoMem],

View File

@ -161,6 +161,8 @@ def hasHWROT32 : Predicate<"Subtarget.hasHWROT32()">;
def true : Predicate<"1">;
def hasPTX31 : Predicate<"Subtarget.getPTXVersion() >= 31">;
//===----------------------------------------------------------------------===//
// Some Common Instruction Class Templates

View File

@ -1689,6 +1689,44 @@ def INT_NVVM_COMPILER_ERROR_64 : NVPTXInst<(outs), (ins Int64Regs:$a),
[(int_nvvm_compiler_error Int64Regs:$a)]>;
// isspacep
def ISSPACEP_CONST_32
: NVPTXInst<(outs Int1Regs:$d), (ins Int32Regs:$a),
"isspacep.const \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_const Int32Regs:$a))]>,
Requires<[hasPTX31]>;
def ISSPACEP_CONST_64
: NVPTXInst<(outs Int1Regs:$d), (ins Int64Regs:$a),
"isspacep.const \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_const Int64Regs:$a))]>,
Requires<[hasPTX31]>;
def ISSPACEP_GLOBAL_32
: NVPTXInst<(outs Int1Regs:$d), (ins Int32Regs:$a),
"isspacep.global \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_global Int32Regs:$a))]>;
def ISSPACEP_GLOBAL_64
: NVPTXInst<(outs Int1Regs:$d), (ins Int64Regs:$a),
"isspacep.global \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_global Int64Regs:$a))]>;
def ISSPACEP_LOCAL_32
: NVPTXInst<(outs Int1Regs:$d), (ins Int32Regs:$a),
"isspacep.local \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_local Int32Regs:$a))]>;
def ISSPACEP_LOCAL_64
: NVPTXInst<(outs Int1Regs:$d), (ins Int64Regs:$a),
"isspacep.local \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_local Int64Regs:$a))]>;
def ISSPACEP_SHARED_32
: NVPTXInst<(outs Int1Regs:$d), (ins Int32Regs:$a),
"isspacep.shared \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_shared Int32Regs:$a))]>;
def ISSPACEP_SHARED_64
: NVPTXInst<(outs Int1Regs:$d), (ins Int64Regs:$a),
"isspacep.shared \t$d, $a;",
[(set Int1Regs:$d, (int_nvvm_isspacep_shared Int64Regs:$a))]>;
// Special register reads
def MOV_SPECIAL : NVPTXInst<(outs Int32Regs:$d),
(ins SpecialRegs:$r),

View File

@ -0,0 +1,35 @@
; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
declare i1 @llvm.nvvm.isspacep.const(i8*) readnone noinline
declare i1 @llvm.nvvm.isspacep.global(i8*) readnone noinline
declare i1 @llvm.nvvm.isspacep.local(i8*) readnone noinline
declare i1 @llvm.nvvm.isspacep.shared(i8*) readnone noinline
; CHECK: is_const
define i1 @is_const(i8* %addr) {
; CHECK: isspacep.const
%v = tail call i1 @llvm.nvvm.isspacep.const(i8* %addr)
ret i1 %v
}
; CHECK: is_global
define i1 @is_global(i8* %addr) {
; CHECK: isspacep.global
%v = tail call i1 @llvm.nvvm.isspacep.global(i8* %addr)
ret i1 %v
}
; CHECK: is_local
define i1 @is_local(i8* %addr) {
; CHECK: isspacep.local
%v = tail call i1 @llvm.nvvm.isspacep.local(i8* %addr)
ret i1 %v
}
; CHECK: is_shared
define i1 @is_shared(i8* %addr) {
; CHECK: isspacep.shared
%v = tail call i1 @llvm.nvvm.isspacep.shared(i8* %addr)
ret i1 %v
}