100ecaccaSChris Bieneman// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s 200ecaccaSChris Bieneman 3*e20bf289SHelena Kotas// XFAIL: * 4*e20bf289SHelena Kotas// Resource indexing will be properly implemented in llvm/llvm-project#95956 5*e20bf289SHelena Kotas 600ecaccaSChris Bienemanconst RWBuffer<float> In; 700ecaccaSChris BienemanRWBuffer<float> Out; 800ecaccaSChris Bieneman 900ecaccaSChris Bienemanvoid fn(int Idx) { 1000ecaccaSChris Bieneman Out[Idx] = In[Idx]; 1100ecaccaSChris Bieneman} 1200ecaccaSChris Bieneman 1300ecaccaSChris Bieneman// This test is intended to verify reasonable code generation of the subscript 1400ecaccaSChris Bieneman// operator. In this test case we should be generating both the const and 1500ecaccaSChris Bieneman// non-const operators so we verify both cases. 1600ecaccaSChris Bieneman 1700ecaccaSChris Bieneman// Non-const comes first. 1800ecaccaSChris Bieneman// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QBAAAMI@Z" 1900ecaccaSChris Bieneman// CHECK: %this1 = load ptr, ptr %this.addr, align 4 2094473f4dSHari Limaye// CHECK-NEXT: %h = getelementptr inbounds nuw %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0 2100ecaccaSChris Bieneman// CHECK-NEXT: %0 = load ptr, ptr %h, align 4 2200ecaccaSChris Bieneman// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4 237eca38ceSHari Limaye// CHECK-NEXT: %arrayidx = getelementptr inbounds nuw float, ptr %0, i32 %1 2400ecaccaSChris Bieneman// CHECK-NEXT: ret ptr %arrayidx 2500ecaccaSChris Bieneman 2600ecaccaSChris Bieneman// Const comes next, and returns the pointer instead of the value. 2700ecaccaSChris Bieneman// CHECK: ptr @"??A?$RWBuffer@M@hlsl@@QAAAAMI@Z" 2800ecaccaSChris Bieneman// CHECK: %this1 = load ptr, ptr %this.addr, align 4 2994473f4dSHari Limaye// CHECK-NEXT: %h = getelementptr inbounds nuw %"class.hlsl::RWBuffer", ptr %this1, i32 0, i32 0 3000ecaccaSChris Bieneman// CHECK-NEXT: %0 = load ptr, ptr %h, align 4 3100ecaccaSChris Bieneman// CHECK-NEXT: %1 = load i32, ptr %Idx.addr, align 4 327eca38ceSHari Limaye// CHECK-NEXT: %arrayidx = getelementptr inbounds nuw float, ptr %0, i32 %1 3300ecaccaSChris Bieneman// CHECK-NEXT: ret ptr %arrayidx 34