LLVM 24.0.0git
DXILOpBuilder.h
Go to the documentation of this file.
1//===- DXILOpBuilder.h - Helper class for build DIXLOp functions ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file This file contains class to help build DXIL op functions.
10//===----------------------------------------------------------------------===//
11
12#ifndef LLVM_LIB_TARGET_DIRECTX_DXILOPBUILDER_H
13#define LLVM_LIB_TARGET_DIRECTX_DXILOPBUILDER_H
14
15#include "DXILConstants.h"
17#include "llvm/IR/IRBuilder.h"
19#include "llvm/Support/Error.h"
21
22namespace llvm {
23class Module;
24class CallInst;
25class Constant;
26class Value;
27class Type;
28
29namespace dxil {
30
32public:
34
35 IRBuilder<> &getIRB() { return IRB; }
36
37 /// Create a call instruction for the given DXIL op. The arguments
38 /// must be valid for an overload of the operation.
40 const Twine &Name = "", Type *RetTy = nullptr);
41
42 /// Try to create a call instruction for the given DXIL op. Fails if the
43 /// overload is invalid.
45 const Twine &Name = "",
46 Type *RetTy = nullptr);
47
48 /// Get a `%dx.types.ResRet` type with the given element type.
49 StructType *getResRetType(Type *ElementTy);
50
51 /// Get a `%dx.types.CBufRet` type with the given element type.
52 StructType *getCBufRetType(Type *ElementTy);
53
54 /// Get the `%dx.types.Handle` type.
56
57 /// Get a constant `%dx.types.ResBind` value.
58 Constant *getResBind(uint32_t LowerBound, uint32_t UpperBound,
59 uint32_t SpaceID, dxil::ResourceClass RC);
60 /// Get a constant `%dx.types.ResourceProperties` value.
62
63 /// Return the name of the given opcode.
64 static const char *getOpCodeName(dxil::OpCode DXILOp);
65
66private:
67 Module &M;
68 IRBuilder<> IRB;
69 VersionTuple DXILVersion;
70 Triple::EnvironmentType ShaderStage;
71};
72
73} // namespace dxil
74} // namespace llvm
75
76#endif
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
Definition Constant.h:44
Tagged union holding either a T or a Error.
Definition Error.h:485
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Definition IRBuilder.h:2990
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Class to represent struct types.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
LLVM Value Representation.
Definition Value.h:75
Represents a version number in the form major[.minor[.subminor[.build]]].
StructType * getResRetType(Type *ElementTy)
Get a dx.types.ResRet type with the given element type.
Expected< CallInst * > tryCreateOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Try to create a call instruction for the given DXIL op.
CallInst * createOp(dxil::OpCode Op, ArrayRef< Value * > Args, const Twine &Name="", Type *RetTy=nullptr)
Create a call instruction for the given DXIL op.
Constant * getResBind(uint32_t LowerBound, uint32_t UpperBound, uint32_t SpaceID, dxil::ResourceClass RC)
Get a constant dx.types.ResBind value.
static const char * getOpCodeName(dxil::OpCode DXILOp)
Return the name of the given opcode.
Constant * getResProps(uint32_t Word0, uint32_t Word1)
Get a constant dx.types.ResourceProperties value.
StructType * getHandleType()
Get the dx.types.Handle type.
StructType * getCBufRetType(Type *ElementTy)
Get a dx.types.CBufRet type with the given element type.
This is an optimization pass for GlobalISel generic memory operations.
DWARFExpression::Operation Op