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