| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s |
| 2 |
|
| 3 |
const RWBuffer<float> In; |
| 4 |
RWBuffer<float> Out; |
| 5 |
|
| 6 |
void fn(int Idx) { |
| 7 |
Out[Idx] = In[Idx]; |
| 8 |
} |
| 9 |
|
| 10 |
// This test is intended to verify reasonable code generation of the subscript |
| 11 |
// operator. In this test case we should be generating both the const and |
| 12 |
// non-const operators so we verify both cases. |
| 13 |
|
| 14 |
// Non-const comes first. |
| 15 |
// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QBAAAMI@Z" |
| 16 |
// CHECK: %this1 = load ptr, ptr %this.addr, align 4 |
| 17 |
// CHECK-NEXT: %h = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0 |
| 18 |
// CHECK-NEXT: %0 = load ptr, ptr %h, align 4 |
| 19 |
// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4 |
| 20 |
// CHECK-NEXT: %arrayidx = getelementptr inbounds float, ptr %0, i32 %1 |
| 21 |
// CHECK-NEXT: ret ptr %arrayidx |
| 22 |
|
| 23 |
// Const comes next, and returns the pointer instead of the value. |
| 24 |
// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QAAAAMI@Z" |
| 25 |
// CHECK: %this1 = load ptr, ptr %this.addr, align 4 |
| 26 |
// CHECK-NEXT: %h = getelementptr inbounds %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0 |
| 27 |
// CHECK-NEXT: %0 = load ptr, ptr %h, align 4 |
| 28 |
// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4 |
| 29 |
// CHECK-NEXT: %arrayidx = getelementptr inbounds float, ptr %0, i32 %1 |
| 30 |
// CHECK-NEXT: ret ptr %arrayidx |