llvm-project/clang/test/CodeGenHLSL/static_global_and_function_in_cb.hlsl
Xiang Li ebe9c7f3e2 [HLSL] CodeGen hlsl cbuffer/tbuffer.
cbuffer A {
  float a;
  float b;
}

will be translated to a global variable.

Something like

struct CB_Ty {
  float a;
  float b;
};

CB_Ty A;

And all use of a and b will be replaced with A.a and A.b.

Only support none-legacy cbuffer layout now.
CodeGen for Resource binding will be in separate patch.
In the separate patch, resource binding will map the resource information to the global variable.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D130131
2022-10-12 21:17:38 -07:00

19 lines
488 B
HLSL

// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple \
// RUN: dxil-pc-shadermodel6.3-library %s \
// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %s
// CHECK-DAG: @[[CB:.+]] = external constant { float }
cbuffer A {
float a;
// CHECK-DAG:@b = internal global float 3.000000e+00, align 4
static float b = 3;
// CHECK:load float, ptr @[[CB]], align 4
// CHECK:load float, ptr @b, align 4
float foo() { return a + b; }
}
float bar() {
return foo();
}