File: SPIRVLLVMUtil.h

package info (click to toggle)
spirv-llvm-translator-19 19.1.10-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,996 kB
  • sloc: cpp: 45,009; ansic: 6,283; lisp: 3,739; sh: 162; python: 58; makefile: 33
file content (36 lines) | stat: -rw-r--r-- 1,194 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//===- SPIRVLLVMUtil.h - SPIR-V LLVM-specific Utility Functions -*- C++ -*-===//
//
// Has inclusions from the LLVM Project, under the Apache License v2.0 with LLVM
// Exceptions. See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
/// \file
///
/// This file defines utility functions dedicated to processing LLVM classes
///
//===----------------------------------------------------------------------===//

#ifndef SPIRV_LIBSPIRV_SPIRVLLVMUTIL_H
#define SPIRV_LIBSPIRV_SPIRVLLVMUTIL_H

#include "llvm/IR/Constants.h"
#include "llvm/Support/Casting.h"

namespace SPIRV {
inline bool isManifestConstant(const llvm::Constant *C) {
  if (llvm::isa<llvm::ConstantData>(C)) {
    return true;
  } else if (llvm::isa<llvm::ConstantAggregate>(C) ||
             llvm::isa<llvm::ConstantExpr>(C)) {
    for (const llvm::Value *Subc : C->operand_values()) {
      if (!isManifestConstant(llvm::cast<llvm::Constant>(Subc)))
        return false;
    }
    return true;
  }
  return false;
}
} // namespace SPIRV

#endif // SPIRV_LIBSPIRV_SPIRVLLVMUTIL_H