/*========================== begin_copyright_notice ============================

Copyright (C) 2026 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#pragma once

#include "common/LLVMWarningsPush.hpp"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Constants.h"
#include "common/LLVMWarningsPop.hpp"
#include "llvmWrapper/IR/DerivedTypes.h"

#include "common/StringMacros.hpp"
#include "debug/DebugMacros.hpp"

#include "BuilderConcepts.h"

namespace llvm {

template <typename Derived> class RenderSurfaceStateBuilder {
protected:
  RenderSurfaceStateBuilder() { checkDerivedRequirements(); }

  static void checkDerivedRequirements() {
    static_assert(DerivedFromIRBuilder<Derived>, "Derived must inherit from llvm::IRBuilderBase");
    static_assert(HasGetCtxBase<Derived>,
                  "Derived must implement getCtx() returning an object with getLLVMContext() and getModule()");
    static_assert(HasSurfaceStateSize<Derived>, "Derived must implement: unsigned getSurfaceStateSize() const");
  }

  Derived &derived() { return static_cast<Derived &>(*this); }
  const Derived &derived() const { return static_cast<const Derived &>(*this); }

protected:
#include "AutoGenRenderSurfaceStatePrivate.h"
public:
#include "AutoGenRenderSurfaceStatePublic.h"

  Value *loadSurfaceBaseAddress(Value *heapBasePtr, Value *surfaceStateOffset, const Twine &Name = "") {
    return _loadSurfaceBaseAddress_64B(heapBasePtr, surfaceStateOffset, Name);
  }
};

} // namespace llvm
