mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
PTX: Emit global arrays with proper sizes
- Emit all arrays as type .b8 and proper sizes in bytes to conform to the output of nvcc llvm-svn: 127584
This commit is contained in:
parent
995d10cfea
commit
a2f7c8557c
@ -316,13 +316,42 @@ void PTXAsmPrinter::EmitVariableDeclaration(const GlobalVariable *gv) {
|
||||
decl += " ";
|
||||
}
|
||||
|
||||
decl += getTypeName(gv->getType());
|
||||
decl += " ";
|
||||
|
||||
decl += gvsym->getName();
|
||||
if (PointerType::classof(gv->getType())) {
|
||||
const PointerType* pointerTy = dyn_cast<const PointerType>(gv->getType());
|
||||
const Type* elementTy = pointerTy->getElementType();
|
||||
|
||||
if (ArrayType::classof(gv->getType()) || PointerType::classof(gv->getType()))
|
||||
decl += "[]";
|
||||
assert(elementTy->isArrayTy() && "Only pointers to arrays are supported");
|
||||
|
||||
const ArrayType* arrayTy = dyn_cast<const ArrayType>(elementTy);
|
||||
elementTy = arrayTy->getElementType();
|
||||
|
||||
// FIXME: isPrimitiveType() == false for i16?
|
||||
assert(elementTy->isSingleValueType() &&
|
||||
"Non-primitive types are not handled");
|
||||
|
||||
// Compute the size of the array, in bytes.
|
||||
uint64_t arraySize = (elementTy->getPrimitiveSizeInBits() >> 3)
|
||||
* arrayTy->getNumElements();
|
||||
|
||||
decl += ".b8 ";
|
||||
decl += gvsym->getName();
|
||||
decl += "[";
|
||||
decl += utostr(arraySize);
|
||||
decl += "]";
|
||||
}
|
||||
else {
|
||||
// Note: this is currently the fall-through case and most likely generates
|
||||
// incorrect code.
|
||||
decl += getTypeName(gv->getType());
|
||||
decl += " ";
|
||||
|
||||
decl += gvsym->getName();
|
||||
|
||||
if (ArrayType::classof(gv->getType()) ||
|
||||
PointerType::classof(gv->getType()))
|
||||
decl += "[]";
|
||||
}
|
||||
|
||||
decl += ";";
|
||||
|
||||
|
@ -1,63 +1,63 @@
|
||||
; RUN: llc < %s -march=ptx | FileCheck %s
|
||||
|
||||
;CHECK: .extern .global .u16 array_i16[];
|
||||
;CHECK: .extern .global .b8 array_i16[20];
|
||||
@array_i16 = external global [10 x i16]
|
||||
|
||||
;CHECK: .extern .const .u16 array_constant_i16[];
|
||||
;CHECK: .extern .const .b8 array_constant_i16[20];
|
||||
@array_constant_i16 = external addrspace(1) constant [10 x i16]
|
||||
|
||||
;CHECK: .extern .local .u16 array_local_i16[];
|
||||
;CHECK: .extern .local .b8 array_local_i16[20];
|
||||
@array_local_i16 = external addrspace(2) global [10 x i16]
|
||||
|
||||
;CHECK: .extern .shared .u16 array_shared_i16[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i16[20];
|
||||
@array_shared_i16 = external addrspace(4) global [10 x i16]
|
||||
|
||||
;CHECK: .extern .global .u32 array_i32[];
|
||||
;CHECK: .extern .global .b8 array_i32[40];
|
||||
@array_i32 = external global [10 x i32]
|
||||
|
||||
;CHECK: .extern .const .u32 array_constant_i32[];
|
||||
;CHECK: .extern .const .b8 array_constant_i32[40];
|
||||
@array_constant_i32 = external addrspace(1) constant [10 x i32]
|
||||
|
||||
;CHECK: .extern .local .u32 array_local_i32[];
|
||||
;CHECK: .extern .local .b8 array_local_i32[40];
|
||||
@array_local_i32 = external addrspace(2) global [10 x i32]
|
||||
|
||||
;CHECK: .extern .shared .u32 array_shared_i32[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i32[40];
|
||||
@array_shared_i32 = external addrspace(4) global [10 x i32]
|
||||
|
||||
;CHECK: .extern .global .u64 array_i64[];
|
||||
;CHECK: .extern .global .b8 array_i64[80];
|
||||
@array_i64 = external global [10 x i64]
|
||||
|
||||
;CHECK: .extern .const .u64 array_constant_i64[];
|
||||
;CHECK: .extern .const .b8 array_constant_i64[80];
|
||||
@array_constant_i64 = external addrspace(1) constant [10 x i64]
|
||||
|
||||
;CHECK: .extern .local .u64 array_local_i64[];
|
||||
;CHECK: .extern .local .b8 array_local_i64[80];
|
||||
@array_local_i64 = external addrspace(2) global [10 x i64]
|
||||
|
||||
;CHECK: .extern .shared .u64 array_shared_i64[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i64[80];
|
||||
@array_shared_i64 = external addrspace(4) global [10 x i64]
|
||||
|
||||
;CHECK: .extern .global .f32 array_float[];
|
||||
;CHECK: .extern .global .b8 array_float[40];
|
||||
@array_float = external global [10 x float]
|
||||
|
||||
;CHECK: .extern .const .f32 array_constant_float[];
|
||||
;CHECK: .extern .const .b8 array_constant_float[40];
|
||||
@array_constant_float = external addrspace(1) constant [10 x float]
|
||||
|
||||
;CHECK: .extern .local .f32 array_local_float[];
|
||||
;CHECK: .extern .local .b8 array_local_float[40];
|
||||
@array_local_float = external addrspace(2) global [10 x float]
|
||||
|
||||
;CHECK: .extern .shared .f32 array_shared_float[];
|
||||
;CHECK: .extern .shared .b8 array_shared_float[40];
|
||||
@array_shared_float = external addrspace(4) global [10 x float]
|
||||
|
||||
;CHECK: .extern .global .f64 array_double[];
|
||||
;CHECK: .extern .global .b8 array_double[80];
|
||||
@array_double = external global [10 x double]
|
||||
|
||||
;CHECK: .extern .const .f64 array_constant_double[];
|
||||
;CHECK: .extern .const .b8 array_constant_double[80];
|
||||
@array_constant_double = external addrspace(1) constant [10 x double]
|
||||
|
||||
;CHECK: .extern .local .f64 array_local_double[];
|
||||
;CHECK: .extern .local .b8 array_local_double[80];
|
||||
@array_local_double = external addrspace(2) global [10 x double]
|
||||
|
||||
;CHECK: .extern .shared .f64 array_shared_double[];
|
||||
;CHECK: .extern .shared .b8 array_shared_double[80];
|
||||
@array_shared_double = external addrspace(4) global [10 x double]
|
||||
|
||||
|
||||
|
@ -1,63 +1,63 @@
|
||||
; RUN: llc < %s -march=ptx | FileCheck %s
|
||||
|
||||
;CHECK: .extern .global .u16 array_i16[];
|
||||
;CHECK: .extern .global .b8 array_i16[20];
|
||||
@array_i16 = external global [10 x i16]
|
||||
|
||||
;CHECK: .extern .const .u16 array_constant_i16[];
|
||||
;CHECK: .extern .const .b8 array_constant_i16[20];
|
||||
@array_constant_i16 = external addrspace(1) constant [10 x i16]
|
||||
|
||||
;CHECK: .extern .local .u16 array_local_i16[];
|
||||
;CHECK: .extern .local .b8 array_local_i16[20];
|
||||
@array_local_i16 = external addrspace(2) global [10 x i16]
|
||||
|
||||
;CHECK: .extern .shared .u16 array_shared_i16[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i16[20];
|
||||
@array_shared_i16 = external addrspace(4) global [10 x i16]
|
||||
|
||||
;CHECK: .extern .global .u32 array_i32[];
|
||||
;CHECK: .extern .global .b8 array_i32[40];
|
||||
@array_i32 = external global [10 x i32]
|
||||
|
||||
;CHECK: .extern .const .u32 array_constant_i32[];
|
||||
;CHECK: .extern .const .b8 array_constant_i32[40];
|
||||
@array_constant_i32 = external addrspace(1) constant [10 x i32]
|
||||
|
||||
;CHECK: .extern .local .u32 array_local_i32[];
|
||||
;CHECK: .extern .local .b8 array_local_i32[40];
|
||||
@array_local_i32 = external addrspace(2) global [10 x i32]
|
||||
|
||||
;CHECK: .extern .shared .u32 array_shared_i32[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i32[40];
|
||||
@array_shared_i32 = external addrspace(4) global [10 x i32]
|
||||
|
||||
;CHECK: .extern .global .u64 array_i64[];
|
||||
;CHECK: .extern .global .b8 array_i64[80];
|
||||
@array_i64 = external global [10 x i64]
|
||||
|
||||
;CHECK: .extern .const .u64 array_constant_i64[];
|
||||
;CHECK: .extern .const .b8 array_constant_i64[80];
|
||||
@array_constant_i64 = external addrspace(1) constant [10 x i64]
|
||||
|
||||
;CHECK: .extern .local .u64 array_local_i64[];
|
||||
;CHECK: .extern .local .b8 array_local_i64[80];
|
||||
@array_local_i64 = external addrspace(2) global [10 x i64]
|
||||
|
||||
;CHECK: .extern .shared .u64 array_shared_i64[];
|
||||
;CHECK: .extern .shared .b8 array_shared_i64[80];
|
||||
@array_shared_i64 = external addrspace(4) global [10 x i64]
|
||||
|
||||
;CHECK: .extern .global .f32 array_float[];
|
||||
;CHECK: .extern .global .b8 array_float[40];
|
||||
@array_float = external global [10 x float]
|
||||
|
||||
;CHECK: .extern .const .f32 array_constant_float[];
|
||||
;CHECK: .extern .const .b8 array_constant_float[40];
|
||||
@array_constant_float = external addrspace(1) constant [10 x float]
|
||||
|
||||
;CHECK: .extern .local .f32 array_local_float[];
|
||||
;CHECK: .extern .local .b8 array_local_float[40];
|
||||
@array_local_float = external addrspace(2) global [10 x float]
|
||||
|
||||
;CHECK: .extern .shared .f32 array_shared_float[];
|
||||
;CHECK: .extern .shared .b8 array_shared_float[40];
|
||||
@array_shared_float = external addrspace(4) global [10 x float]
|
||||
|
||||
;CHECK: .extern .global .f64 array_double[];
|
||||
;CHECK: .extern .global .b8 array_double[80];
|
||||
@array_double = external global [10 x double]
|
||||
|
||||
;CHECK: .extern .const .f64 array_constant_double[];
|
||||
;CHECK: .extern .const .b8 array_constant_double[80];
|
||||
@array_constant_double = external addrspace(1) constant [10 x double]
|
||||
|
||||
;CHECK: .extern .local .f64 array_local_double[];
|
||||
;CHECK: .extern .local .b8 array_local_double[80];
|
||||
@array_local_double = external addrspace(2) global [10 x double]
|
||||
|
||||
;CHECK: .extern .shared .f64 array_shared_double[];
|
||||
;CHECK: .extern .shared .b8 array_shared_double[80];
|
||||
@array_shared_double = external addrspace(4) global [10 x double]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user